Reciver中intent = new Intent(context, MessageDetailsaActivity_.class); intent.putExtra("freshMessageId", String.valueOf(push.getObid()));intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);PendingIntent pi = PendingIntent.getActivity(context, 0, intent, Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | PendingIntent.FLAG_UPDATE_CURRENT); Notification notification = new Notification.Builder(context) .setSmallIcon(R.drawable.push) .setTicker(pBase.getNotificationMsg()) .setWhen(System.currentTimeMillis())//通知栏时间,一般是直接用系统的 .setContentTitle(pBase.getNotificationTitle()) .setContentText(pBase.getNotificationContent()) .setDefaults(Notification.DEFAULT_VIBRATE | Notification.DEFAULT_LIGHTS | Notification.DEFAULT_SOUND)//向通知添加声音、闪灯和振动效果的最简单、最一致的方式是使用当前的用户默认设置, .setContentIntent(pi).build();
其中这一句:PendingIntent pi = PendingIntent.getActivity(context, 0, intent, Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | PendingIntent.FLAG_UPDATE_CURRENT);
由于最开始我一直没加标红的代码,结果接收的值总是不对。。。。