Android notification点击跳转到Activity,点击返回跳转,前一条消息目标Intent的值不被后面的消息覆盖,getActivities第二个参数必须区分开来

NotificationCompat.Builder builder = new NotificationCompat.Builder(mActivity);
builder.setSmallIcon(R.mipmap.img_logo);

builder.setContentTitle("title");
builder.setContentText("content");
builder.setAutoCancel(true);
builder.setDefaults(NotificationCompat.DEFAULT_ALL);


//设置点击通知跳转的activity
Intent resultIntent = new Intent(MyApp.getInstance(), ChatActivity.class);
resultIntent.putExtra("friendId", srcUin);

Intent mIntent = new Intent(MyApp.getInstance(), HomeActivity.class);//点击返回的界面
mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);

Intent[] intents = new Intent[]{mIntent, resultIntent};
//resultIntent.putExtra("friendId", SrcUin);的值不被后来的消息覆盖,getActivities第二个参数必须区分开来
PendingIntent pendingIntent = PendingIntent.getActivities(MyApp.getInstance(), srcUin, intents, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(pendingIntent);
MyApp.getInstance().getNotificationManager().notify(srcUin, builder.build());

你可能感兴趣的:(android,android,notification)