I have a question with respect to broadcast receiver and mainthread handling it.
If main thread is doing some computation(or you can say executing a code under a constructor or in a method) and broadcast receiver onReceive() is triggered? Which task will be picked up
Constructor/Method will complete its execution and then onReceive is called. (This is what my understanding is)
onReceive will be triggered first
Constructor/Method will complete its execution and then onReceive is called should be the answer, because BroadcastReceivers are always called on the main thread.
void onReceive (Context context, Intent intent).
This method is called when the BroadcastReceiver is receiving an Intent broadcast. During this time you can use the other methods on BroadcastReceiver to view/modify the current result values. This method is always called within the main thread of its process, unless you explicitly asked for it to be scheduled on a different thread using registerReceiver(BroadcastReceiver, IntentFilter, String, android.os.Handler).
You are right....
1) First the execution of main thread will complete then only any pending task will be executed.
2) If main thread takes too long to complete its task it will simply give an exception
something like this :
Application "AndroidThreadDemo" not responding.
Please see this link for more info.. I am sure it will help you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.