Reputation: 2268
My question is quite simple but I'm not able to find a satisfying answer. The question is: Does my thread run on UI Thread if I call Looper.prepare()
at the start of my Runnable
?
I know Looper
is for MessageQueue
and exchanging data between threads but does it make the code run on UI Thread?
Below code will explain:
@Override
public void onReceive(final Context context, Intent intent) {
if(intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
Runnable runnable = new Runnable() {
@Override
public void run() {
Looper.prepare();
// ... some code ... //
Looper.loop();
}
};
Thread thread = new Thread(runnable);
thread.start();
}
}
Upvotes: 1
Views: 399
Reputation: 75629
No, it will not make your thread run on UI thread. For more info see: Communicating with the UI Thread
Upvotes: 1