Android 多个按钮具有挂起的remoteView通知意图

Android 多个按钮具有挂起的remoteView通知意图,android,notifications,android-pendingintent,remoteview,Android,Notifications,Android Pendingintent,Remoteview,我有一个使用remoteView的通知。在通知上,我有3个按钮,每个按钮都有自己的悬挂式帐篷。出于某种原因,只有我用SetOnClickPendingEvent添加的最后一个PendingEvent有效 下面是一些例子 Intent intentPause = new Intent(context, BluetoothConnectionService.class); intentPause.putExtra("pause", device.device.getAddress()

我有一个使用remoteView的通知。在通知上,我有3个按钮,每个按钮都有自己的悬挂式帐篷。出于某种原因,只有我用SetOnClickPendingEvent添加的最后一个PendingEvent有效

下面是一些例子

    Intent intentPause = new Intent(context, BluetoothConnectionService.class);
    intentPause.putExtra("pause", device.device.getAddress());
    Intent intentIncrease = new Intent(context, BluetoothConnectionService.class);
    intentIncrease.putExtra("inc", device.device.getAddress());
    PendingIntent pendingIntentPause = PendingIntent.getService(context, 0, intentPause, PendingIntent.FLAG_CANCEL_CURRENT);
    PendingIntent pendingIntentIncrease = PendingIntent.getService(context, 0, intentIncrease, PendingIntent.FLAG_CANCEL_CURRENT);

    RemoteViews expandedView = new RemoteViews(context.getPackageName(), R.layout.notification_layout);

    expandedView.setOnClickPendingIntent(R.id.noti_pause_heat_button, pendingIntentPause);
    expandedView.setOnClickPendingIntent(R.id.noti_inc_heat_button, pendingIntentIncrease);



Notification notification = new Notification.Builder(context)
        .setContentTitle(this.device.getName())
                        .setSmallIcon(R.drawable.inu_small)
                        .setContentText("" + this.notificationId)
        .setContent(expandedView)
                    .build();
为每个PendingDent使用getService的不同requestCode第二个参数。例如

为每个PendingDent使用getService的不同requestCode第二个参数。例如


谢谢你,先生!我不知道为什么你的答案没有被接受谢谢你的先生!我不知道为什么你的回答没有被接受
PendingIntent pendingIntentPause = PendingIntent.getService(context, 0, intentPause, PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent pendingIntentIncrease = PendingIntent.getService(context, 1, intentIncrease, PendingIntent.FLAG_UPDATE_CURRENT);