This article demonstrates how to use Core Java in android for concurrent Executor,
Question: Why we should use Core Java Executor? why not AsyncTask?
Answer: The reason is android based SDK announced AsyncTask is Deprecated
Question: So simple core java Runnable is good?
Answer: Not really, But in combination with java.util.concurrent.Executor Runnable is good
Question: Is this told by android SDK documentation
Answer: Yes, As shown below
The below source code provides one approach to achieve the same
The basic idea is
ex = Executors.newSingleThreadExecutor();
ex.execute(th);
Where the th is your thread class object, how you create the thread class is up to
Now how to access the UI ?
The basic idea of accessing the UI is runOnUiThread
runOnUiThread(new Runnable() {
@Override
public void run() {
//Access UI
}
});
Article Ends here :)