多个按钮,具有与remoteView通知的待处理意图

时间:2015-05-01 15:29:30

标签: android notifications android-pendingintent remoteview

我有一个使用remoteView的通知。在通知上我有3个按钮,每个按钮都有自己的pendingIntent。由于某种原因,我使用setOnClickPendingIntent添加的最后一个pendingIntent工作。

以下是一些

    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();

1 个答案:

答案 0 :(得分:4)

为每个list.get(index)使用不同的A "Property" BsonClassMap.MapProperty A "Field" BsonClassMap.MapField A "Member" BsonClassMap.MapMember requestCode的第二个参数)。 E.g。

getService