GCM push notifications on android 3.1 : disable broadcast receiver

夙愿已清 提交于 2019-12-01 03:03:57

问题


There is the problem with android push notifications (GCM) on android 3.1 : when my app is CLOSED - broadcast receiver which should handle GCM push messages (Intents) is never called.

In lower versions of android everything works just fine. Broadcast reciever is always called (even when app is closed).

I know that from Android 3.1 there is new concept: when application is not running it is in "stopped" state: http://developer.android.com/about/versions/android-3.1.html#launchcontrols

So if you want to start "stopped" application via Intent - you should add FLAG_INCLUDE_STOPPED_PACKAGES flag to Intent.

But problem is that i can't add FLAG_INCLUDE_STOPPED_PACKAGES flag to GCM Intent because GCM Intents (i mean "com.google.android.c2dm.intent.RECEIVE" and "com.google.android.c2dm.intent.REGISTRATION") are thrown by the OS.

So my question is: how can i handle push messages (on android 3.1) from GCM via broadcast reciever in situation when application (in which broadcastreceiver is registered) is closed (is in "stopped" state) ?


回答1:


how can i handle push messages (on android 3.1) from GCM via broadcast reciever in situation when application (in which broadcastreceiver is registered) is closed (is in "stopped" state) ?

You can't. If the user force-stops your app, nothing of your app will run again (on Android 3.1+) unless invoked manually, such as the user launching one of your activities. Your objective is to give the user no reason to force-stop your app.



来源:https://stackoverflow.com/questions/12302812/gcm-push-notifications-on-android-3-1-disable-broadcast-receiver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!