问题描述:

The GcmListenerService handles wakelock for us. The onMessageReceived method runs in a thread pool (not on the main UI thread) so it seems as if the intention was to allow long running tasks to be executed on this method.

My question is whether there is some kind of a runtime limit of this method when GCM is received. Basically I would want to download a few images during the run of this method and then post a notification to the user, and be certain that the device does not go to sleep and finishes its execution.

As far as I understand, the fact that GcmReceiver and GcmListenerService take care of a wakeup lock for us, allows us to do the heavy tasks on this method and be certain that it finishes. Is this true?

网友答案:

Hope that not is too late for the answer but about the question, yes you can do long running process(in your case I/O) as the GcmListenerService class extends android.app.Service and you can still notify the user that you are processing something in background and show the process of it via a Notification.

Android Documentation - Displaying a fixed-duration progress indicator

相关阅读:
Top