【发布时间】:2022-01-20 12:52:16
【问题描述】:
伙计们,我正在使用 FCM 向我的 android 应用程序发送通知,它工作正常,但是当我点击通知时,它会将我发送到我在此处设置的特定活动:
@Override
public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
Intent intent = new Intent(this, activity_togo_to.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "101")
.setSmallIcon(R.drawable.ic_add)
.setContentTitle(remoteMessage.getNotification().getTitle())
.setContentText(remoteMessage.getNotification().getBody())
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
// Set the intent that will fire when the user taps the notification
.setContentIntent(pendingIntent)
.setAutoCancel(true);
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
// notificationId is a unique int for each notification that you must define
notificationManager.notify(1, builder.build());
}
我的问题我不想在点击通知时转到相同的活动。
所以我的通知系统是这样工作的:
我在 MySQL 数据库 A 和 B 中有两个表:
当A表添加一行时-->推送标题为:“有一个新项目A”
当 B 表添加一行时 --> 推送标题为:“有一个新项目 B”
当我点击通知时:
标题为:“有一个新项目A”-->转到活动A
标题为:“有一个新项目B”-->转到活动B
我怎样才能做到这一点,我真的需要它。
感谢任何帮助。 如果不可能,请告诉我。
【问题讨论】:
标签: java android firebase firebase-cloud-messaging