Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

For GcmListenerService is onMessageReceived background?

When I extend GcmListenerService, is onMessageReceived running in a background process or is it on the UI thread? I need to know if I may make network calls inside the method body without using an asyncTask or such.

I looked at the source code and sure enough it is a vanilla service with no handlers. But there is a bit of code about THREAD_POOL_EXECUTOR and a number of apparently obfuscated stuff.

like image 654
androiddude Avatar asked Mar 15 '16 19:03

androiddude


1 Answers

When I extend GcmListenerService, is onMessageReceived running in a background process or is it on the UI thread? I need to know if I may make network calls inside the method body without using an asyncTask or such.

Yes you can make network calls inside onMessageReceived() method because it is running in a background process. For example, you can download an image in this method before displaying it on notification using big image notification style.

like image 189
maohieng Avatar answered Oct 03 '22 10:10

maohieng