我通过来自通知的PendingIntent启动我的应用,看起来像这样:
PendingIntent pendingIntent = PendingIntent.getActivity
(getApplicationContext(), 1 , intent, PendingIntent.FLAG_ONE_SHOT);
我设置了一个额外的任务,以便执行特定任务并通过以下方式获取:
GcmListenerService.PushNotificationTrigger pushNotificationTrigger = (GcmListenerService.PushNotificationTrigger) intent.getSerializableExtra(
GcmListenerService.GCM_PUSH_TRIGGER_KEY);
执行任务后,我通过反压(简单onBackPressed)“关闭”应用程序。再次打开应用程序时,它会再次执行该任务。我调试它并得出结果,pushNotificationTrigger仍然是相同的。 Intent和我关闭它之前有相同的额外内容。在我看来,就像Android缓存它一样。
我已经尝试过的和没有用过的东西:
在第一次阅读之后删除额外内容:
intent.removeExtra(GcmListenerService.GCM_PUSH_TRIGGER_KEY);
用finish()
覆盖onBackPressed有解决方法吗?