Looper.getMainLooper()
Runnable task = getTask();
new Handler(Looper.getMainLooper()).post(task);
Activity#runOnUiThread()
Runnable task = getTask();
runOnUiThread(task);
public final void runOnUiThread(Runnable action) {
if (Thread.currentThread() != mUiThread) {
mHandler.post(action);
} else { //Exécuter directement pour les threads de l'interface utilisateur
action.run();
}
}
Recommended Posts