1

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?

Joel
  • 5,949
  • 12
  • 42
  • 58
  • if you want to send images in notification you can send a data load of 4kb. so you can send a thumbnail under the size of data payload. – Devendra Singh May 11 '16 at 07:36
  • @DevendraSingh, for that matter, let's say I want to do some more network calls.. I mostly want to understand what is allowed on the thread (i.e. the time limit) – Joel May 11 '16 at 07:38
  • [This](http://stackoverflow.com/questions/24840282/load-image-from-url-in-notification-android) may help you. as it is downloading images from external server. – Devendra Singh May 11 '16 at 07:40

1 Answers1

0

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

eOnOe
  • 2,883
  • 2
  • 12
  • 7