在android系统中,FCM通知到来,应用程序处于后台状态,点击该应用程序后,它会重定向到默认活动(LoginActivity),但我想导航到指定的活动(HomeActivity)。
NotificationCompat.Builder notification = new NotificationCompat.Builder(this, "CHANNEL_1");
notification/*.setSound(soundUri)*/
.setSmallIcon(R.drawable.ic_photo_camera_black_24dp)
.setColor(getResources().getColor(R.color.colorAccent))
.setAutoCancel(true)
.setContentTitle(title)
.setContentText(message);
Intent intent = new Intent(this, HomeActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent,
0);
notification.setContentIntent(pendingIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(1, notification.build());
答案 0 :(得分:0)
您将需要从api / json部分传递一个活动参数。从您的应用程序一侧,您将检查活动中殿,然后相应地打开
请参阅此解决方案https://stackoverflow.com/a/39665485/6442746,以获取更多见解。
答案 1 :(得分:0)