Android - PendingIntent 不调用 onCreate
Android - PendingIntent does not call onCreate
我的 GcmListenerService 一切正常 如果 activity 尚未 运行。
我点击通知,应用程序以右 activity 开头,实际上是 EventHistoryActivity
。
但是,如果 EventHistoryActivity
已经是 运行,则什么也不会发生。
我希望调用 onCreate
但它没有发生。
我在 sendNotification
方法中这样做:
resultIntent = new Intent(this, EventHistoryActivity.class);
resultIntent.putExtra("reload", true);
PendingIntent resultPendingIntent = PendingIntent.getActivity(this, 0, resultIntent, PendingIntent.FLAG_CANCEL_CURRENT);
我也试过 PendingIntent.FLAG_UPDATE_CURRENT
和 PendingIntent.FLAG_ONE_SHOT
但没有成功。
问题出在哪里?
同样,如果应用 运行 但 EventHistoryActivity
不是,则一切正常。
我是不是做错了什么或者不是 onCreate
我应该调用的方法?
您可能会接到 onNewIntent
的电话
This is called for activities that set launchMode to "singleTop" in
their package, or if a client used the FLAG_ACTIVITY_SINGLE_TOP flag
when calling startActivity(Intent). In either case, when the activity
is re-launched while at the top of the activity stack instead of a new
instance of the activity being started, onNewIntent() will be called
on the existing instance with the Intent that was used to re-launch
我的 GcmListenerService 一切正常 如果 activity 尚未 运行。
我点击通知,应用程序以右 activity 开头,实际上是 EventHistoryActivity
。
但是,如果 EventHistoryActivity
已经是 运行,则什么也不会发生。
我希望调用 onCreate
但它没有发生。
我在 sendNotification
方法中这样做:
resultIntent = new Intent(this, EventHistoryActivity.class);
resultIntent.putExtra("reload", true);
PendingIntent resultPendingIntent = PendingIntent.getActivity(this, 0, resultIntent, PendingIntent.FLAG_CANCEL_CURRENT);
我也试过 PendingIntent.FLAG_UPDATE_CURRENT
和 PendingIntent.FLAG_ONE_SHOT
但没有成功。
问题出在哪里?
同样,如果应用 运行 但 EventHistoryActivity
不是,则一切正常。
我是不是做错了什么或者不是 onCreate
我应该调用的方法?
您可能会接到 onNewIntent
的电话This is called for activities that set launchMode to "singleTop" in their package, or if a client used the FLAG_ACTIVITY_SINGLE_TOP flag when calling startActivity(Intent). In either case, when the activity is re-launched while at the top of the activity stack instead of a new instance of the activity being started, onNewIntent() will be called on the existing instance with the Intent that was used to re-launch