Starting Synthesis from a Broadcast Receiver

I want to know if running syntheses from a broadcast receiver is considered bad practice? I am mainly registered on google C2DM server, and then when I intercept the registered broadcast receiver, I want to send it to my server.

What is the best way to do this?

+8
android android-c2dm
source share
2 answers

Yes, this is considered bad practice. This is because if you start AsyncTask with BroadcastReceiver , Android can kill your process if onReceive() back and there are no active components active.

The correct way is to start the Service from BroadcastReceiver . And this Service should manage AsyncTask . Thus, Android will know about the active component, and Android will not kill it prematurely (unless other critical conditions arise, for example, insufficient memory).

+18
source share

Starting with Honeycomb, you can call goAsync () , and then you have 10 seconds or so, do your work asynchronously.

An example of use can be shown here .

+2
source share

All Articles