一定要保证
修改后--->正确的方然:
notificationManager.notify(0,builder.build());这段代码写在setContentIntent()方法之后否者无效.
之前点击无效的代码是这样写的---->错误的方法:
notificationManager.notify(0,builder.build());
//点击通知栏跳转到聊天界面
Intent intent = new Intent(this,ChatActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
builder.setContentIntent(pendingIntent);修改后--->正确的方然:
//点击通知栏跳转到聊天界面
Intent intent = new Intent(this,ChatActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
builder.setContentIntent(pendingIntent);
notificationManager.notify(0,builder.build());
本文介绍了一种解决Android通知栏点击后无法正确跳转到指定Activity的问题。关键在于确保设置点击意图代码位于调用notificationManager.notify()之前,以确保通知栏点击事件能够正确触发。

1万+

被折叠的 条评论
为什么被折叠?



