我怎样才能收到从GCM通知时,应用程序已停止应用程序、通知、GCM

2023-09-12 22:51:42 作者:幸福也能呱呱呱!

GCMIntentService(扩展GCMBaseIntentService)将不会收到通知,如果应用程序没有运行。

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

在启动停止的应用程序的控制 注意,系统增加FLAG_EXCLUDE_STOPPED_PACKAGES到所有的广播意图。它这样做是从后台服务prevent广播从stoppped应用程序无意或不必要的启动组件。后台服务或应用程序可以通过添加FLAG_INCLUDE_STOPPED_PACKAGES标志广播应该允许激活停止应用程序意图覆盖此行为。

有没有办法来解决这个问题的设置? 谢谢

解决方案   

GCMIntentService(扩展GCMBaseIntentService)将不会收到通知,如果应用程序没有运行。

是的,会的。你的问题的其余部分,不过,有一点做的应用程序是的运行的,而是它是否已被用户运行之前。这个词是什么停在你引用的不是不运行的段落意思,但再presents的状态,应用程序是:

在第一次安装时,之前的东西手动调用的组件(例如,用户启动一个活动)

用户强制停止该应用程序,直到有手动调用的组件(例如,用户启动一个活动)后

(我真的很希望他们拿出一个比较有特色的形容词不是停止这个......)

  

有没有办法来解决这个问题设置?

没有。如果用户强制停止您的应用程序,他们表示,他们不希望自己的应用程序再次运行,以任何理由,直到它们手动重新启动它。你的目标是让用户没理由逼停你的应用程序。请注意,我的意思是强制停机(即,PSS从设置了强制停止按钮$ P $) - 普通的任务管理器,或者从近期任务列表中的Andr​​oid 4.x的刷卡,不会有这种效果

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

解决方案

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.