Starting with Honeycomb (API 11) , Android has a feature to allow the broadcastReceiver run in an async way, providing it about 10 seconds before it ass
You can find short explanation here.
Use goAsync()
if you want to handoff the processing inside of your BroadcastReceiver
's onReceive()
method to another thread. The onReceive()
method can then be finished there. The PendingResult is passed to the new thread and you have to call PendingResult.finish()
to actually inform the system that this receiver can be recycled.
For example:
final PendingResult result = goAsync();
Thread thread = new Thread() {
public void run() {
int i;
// Do processing
result.setResultCode(i);
result.finish();
}
};
thread.start();