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
}
}
:)