PendingIntent requestCode

PendingIntent android.app.PendingIntent.getBroadcast(Context context, int requestCode, Intent intent, int flags)requestCode 在此处必须得设置,否者后面的PendingIntent将覆盖前面的 PendingIntent中的数据


		Intent broadIntent = new Intent(MReciever.NOTIFY_ACTION);
		broadIntent.putExtra(MReciever.NOTIFY_KEY, MReciever.VALUE_PREVIOUS);
		PendingIntent pendingIntent_pre = PendingIntent.getBroadcast(this, 0, broadIntent, PendingIntent.FLAG_UPDATE_CURRENT);
		remoteViews.setOnClickPendingIntent(R.id.imageButton_previous, pendingIntent_pre);

		broadIntent.putExtra(MReciever.NOTIFY_KEY, MReciever.VALUE_PALY_PAUSE);
		PendingIntent pendingIntent_play = PendingIntent.getBroadcast(this, 1, broadIntent, PendingIntent.FLAG_UPDATE_CURRENT);
		remoteViews.setOnClickPendingIntent(R.id.imageButton_play, pendingIntent_play);

		broadIntent.putExtra(MReciever.NOTIFY_KEY, MReciever.VALUE_NEXT);
		PendingIntent pendingIntent_next = PendingIntent.getBroadcast(this, 2, broadIntent, PendingIntent.FLAG_UPDATE_CURRENT);
		remoteViews.setOnClickPendingIntent(R.id.ImageButton_next, pendingIntent_next);

//		broadIntent.putExtra(MReciever.NOTIFY_KEY, MReciever.VALUE_OPEN_ACTIVITY);
//		PendingIntent pendingIntent_info = PendingIntent.getBroadcast(this, 0, broadIntent, PendingIntent.FLAG_UPDATE_CURRENT);
//		remoteViews.setOnClickPendingIntent(R.id.layout_info, pendingIntent_info);

		notification.setSmallIcon(android.R.drawable.ic_dialog_email);// 必须设置此图标,否则notify不显示:此图标为,通知栏显示的小图标
		notification.setContent(remoteViews);
		notificationManager.notify(1, notification.build());



你可能感兴趣的:(PendingIntent requestCode)