【发布时间】:2018-10-11 11:15:20
【问题描述】:
Intent i = new Intent(this, MainActivity.class);
i.addFlags(Intent.FLAG_FROM_BACKGROUND);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT| PendingIntent.FLAG_IMMUTABLE);
NotificationCompat.Builder builder = (NotificationCompat.Builder) new NotificationCompat.Builder(this).setAutoCancel(true).setContentTitle(title).setContentText(body).setSmallIcon(R.drawable.atlantic_applogo).setLargeIcon(icon).setDefaults(Notification.DEFAULT_ALL).setContentIntent(pendingIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(0, builder.build());
当应用程序从应用程序图标打开时它工作完美,但是当应用程序从通知打开时,如果应用程序在前台,点击新通知时没有任何反应。
【问题讨论】:
-
发布您的清单
-
-
-
以后,请编辑您的原始问题并添加任何缺失的代码或日志。在 cmets 中提供这些东西并不好,因为它很难阅读。
-
请发布您的问题的答案,或删除问题(如果不再相关)。这将从开放问题列表中删除该问题,并可能帮助其他有类似问题的人。如果您回答问题,您可以接受自己的答案。
标签: android android-intent firebase-cloud-messaging android-pendingintent