Is onLoadFinished() asynchronous (background thread)?
android, android-loadermanager
Solution
If you have called `init()` from the UI thread, `onLoadFinished()` will definitely be called on the UI thread. In cases when you call from background for example an `AsyncTaskLoader` the thread that will be notified about the outcome will be the thread from where you init loader.
...But you still can do the following:
@Override
public void onLoadFinished(Loader<String> arg0, String arg1) {
Runnable populate = new Runnable(){
@Override
public void run() {
//your code
}
};
if (Looper.getMainLooper().getThread() == Thread.currentThread()) {
//on Ui thread
populate.run();
}else{
this.runOnUiThread(populate); //or use handler to run the runnable
}
}
:)
Problem
I am currently looking at using a loader manager to populate my expandablelistview in a drawerlayout. I cannot find anywhere in the documentation if the callback function onLoadFinished() is running on the UI thread or on a background thread. Is it on a background thread?