我这样显示我的通知。
// Create an Intent for the activity you want to start
Intent homeIntent = new Intent(context, HomeActivity.class);
homeIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pendingIntent=PendingIntent.getActivity(context,0,homeIntent,PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context, MATCHES_CHANNEL_ID)
.setSmallIcon(R.drawable.ic_avengers)
.setContentTitle(remoteMessage.getData().get("Title"))
.setContentText(remoteMessage.getData().get("Body"))
.setContentIntent(pendingIntent)
.setColor(ContextCompat.getColor(context, R.color.colorAccent))
.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.user_avatar))
.setDefaults(Notification.DEFAULT_ALL)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(remoteMessage.getData().get("Body")));
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
// notificationId is a unique int for each notification that you must define
notificationManager.notify(10, mBuilder.build());
但是无论我做什么,作为我根源的家庭活动标志似乎都不起作用。我的HomeActivity可以推送到用户在我的应用程序中的任何位置。
我希望当前的家庭活动副本排在最前面,其余的应该销毁。