android - Is there any reason to continue using IntentService for handling GCM messages? -
as know, google changed gcm documentation, , claim intentservice
no longer required handling arriving gcm messages. handling can done in broadcastreceiver
.
when trying figure out if there reason continue using intentservice
, came across quote:
a service (typically intentservice) wakefulbroadcastreceiver passes off work of handling gcm message, while ensuring device not go sleep in process. including intentservice optional—you choose process messages in regular broadcastreceiver instead, but realistically, apps use intentservice.
why apps use intentservice
? there scenarios in handling gcm message directly in broadcastreceiver
won't work?
why apps use intentservice?
because whatever doing in response message take more 1-2ms, means want work off main application thread. common pattern doing in response broadcast delegate work intentservice
.
so, if work in response gcm message involves:
- disk i/o
- further network i/o (e.g., retrieving additional data web service)
- substantial calculations (e.g., image processing)
you want use intentservice
perform work.
Comments
Post a Comment