Dij*_*ark 11 java android push-notification google-cloud-messaging
我在Android中使用推送通知.当我收到推送通知时,我想打开应用程序,如果它仍在运行,否则它应该打开它的新实例.
我在用
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent,
Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_SINGLE_TOP |
Intent.FLAG_ACTIVITY_NEW_TASK);
Run Code Online (Sandbox Code Playgroud)
但是当我现在收到推送通知并点击它时,没有任何反应.
我怎样才能通过使用flagIntents实现这一目标?
Dav*_*ser 15
你需要在上面设置Intent标志Intent.您在调用中指定了它们以获取a PendingIntent.试试这个:
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_SINGLE_TOP |
Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
notificationIntent, 0);
Run Code Online (Sandbox Code Playgroud)