Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I receive notifications from GCM when application is stopped

GCMIntentService (extends GCMBaseIntentService) doesn't receive notifications if the application is not running.

From : http://developer.android.com/about/versions/android-3.1.html

Launch controls on stopped applications Note that the system adds FLAG_EXCLUDE_STOPPED_PACKAGES to all broadcast intents. It does this to prevent broadcasts from background services from inadvertently or unnecessarily launching components of stoppped applications. A background service or application can override this behavior by adding the FLAG_INCLUDE_STOPPED_PACKAGES flag to broadcast intents that should be allowed to activate stopped applications.

Is there a way to get around this setting? Thanks

like image 666
Greg Avatar asked Jul 23 '12 14:07

Greg


1 Answers

GCMIntentService (extends GCMBaseIntentService) doesn't receive notifications if the application is not running.

Yes, it will. The rest of your question, though, has little to do with whether the application is running, but rather whether it has been run by the user before. What the word "stopped" means in the paragraph you quote is not "not running", but represents a state that an application is in:

  • when it is first installed, before something manually invokes a component (e.g., user launches an activity)

  • after the user force-stops the app, until something manually invokes a component (e.g., user launches an activity)

(and I really really wish they had come up with a more distinctive adjective than "stopped" for this...)

Is there a way to get around this setting?

No. If the user force-stops your app, they are indicating that they do not want your app to run again, for any reason, until they manually launch it again. Your objective is to give the user no reason to force-stop your app. Note that I do mean "force-stop" (i.e., press the "Force Stop" button from Settings) -- ordinary task managers, or swiping from the Recent Tasks list in Android 4.x, does not have this effect.

like image 109
CommonsWare Avatar answered Oct 11 '22 09:10

CommonsWare