Android启动服务的通知操作,不包括额外的意图

Android启动服务的通知操作,不包括额外的意图,android,android-intent,Android,Android Intent,我有一个通知,它有两个操作,接受和拒绝,以及启动服务的挂起内容,请求更新服务。我将额外内容放入制作pendingent的意图中(通过pendingent#getService)。问题是,当服务启动时,额外的内容并不符合传递到服务#onStartCommand中的意图 通知签发人: NotificationCompat.Builder n = new NotificationCompat.Builder(context) .setDefaults(Notificat

我有一个通知,它有两个操作,
接受
拒绝
,以及启动服务的
挂起内容
请求更新服务
。我将额外内容放入制作
pendingent
意图中(通过
pendingent#getService
)。问题是,当服务启动时,额外的内容并不符合传递到
服务#onStartCommand
中的意图

通知签发人:

NotificationCompat.Builder n = new NotificationCompat.Builder(context)
                .setDefaults(Notification.DEFAULT_ALL)
                .setSmallIcon(R.drawable.logo_small)
                .setContentTitle(notification.getText())
                .setContentText(context.getString(R.string.app_name))
                .setContentIntent(getOpenAppPendingIntent())
                .setOngoing(false)
                .setStyle(new NotificationCompat.BigTextStyle().bigText(text));

Intent actionAccept = new Intent(context, UpdateRequestUpdater.class);
actionAccept.putExtra(KeysAndCodes.UPDATE_REQUEST_ID, notificationRequestId);
actionAccept.putExtra(KeysAndCodes.UPDATE_REQUEST_NOTIFICATION_ID, notificationId);
actionAccept.setAction(KeysAndCodes.UPDATE_REQUEST_UPDATER_ACCEPT);

PendingIntent acceptPendingIntent = PendingIntent.getService(context, 0, actionAccept, 0);

Intent actionDecline = new Intent(context, RequestUpdater.class);

actionDecline.putExtra(KeysAndCodes.UPDATE_REQUEST_ID, notificationRequestId);

actionDecline.putExtra(KeysAndCodes.UPDATE_REQUEST_NOTIFICATION_ID, notificationId);
actionDecline.setAction(KeysAndCodes.UPDATE_REQUEST_UPDATER_DECLINE);

PendingIntent declinePendingIntent = PendingIntent.getService(context, 0, actionDecline, 0);

n.addAction(R.drawable.ic_action_accept, getString(R.string.accept_request), acceptPendingIntent);
n.addAction(R.drawable.ic_action_cancel, getString(R.string.decline_request), declinePendingIntent);

NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(notification.getId(), n.build());
RequestUpdaterService.java

@Override
public int onStartCommand(Intent intent, int flags, int startId) {

    Integer requestId = intent.getIntExtra(KeysAndCodes.UPDATE_REQUEST_ID, 0);
    Integer notificationId = intent.getIntExtra(KeysAndCodes.UPDATE_REQUEST_NOTIFICATION_ID, 0);
...
}

每当启动
RequestUpdaterService
时,
requestId
notificationId
总是
0
。我做错了什么?

尝试更改此行:

PendingIntent acceptPendingIntent = PendingIntent.getService(context, 0, actionAccept, 0);
为此:

PendingIntent acceptPendingIntent = PendingIntent.getService(context, 0, actionAccept, PendingIntent.FLAG_UPDATE_CURRENT);