gpt4 book ai didi

android - 通知中的操作不执行任何操作

转载 作者:行者123 更新时间:2023-11-30 00:13:00 24 4
gpt4 key购买 nike

这是我的代码:

  Intent notificationIntent = new Intent(this, PSTimelineFragmentsActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(PSLocationService.this);
mBuilder.setPriority(Notification.PRIORITY_MAX);
mBuilder.setContentTitle(getText(R.string.passenger_name_long));
mBuilder.setContentText(getText(R.string.service_subtitle));
mBuilder.setSmallIcon(R.drawable.notification_icon);
mBuilder.setContentIntent(pendingIntent);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
Intent action1Intent = new Intent(PSLocationService.this, NotificationActionService.class)
.setAction("autopilot").putExtra("autopilot", "autopilot");
PendingIntent action1PendingIntent = PendingIntent.getService(PSLocationService.this, 0,
action1Intent, PendingIntent.FLAG_ONE_SHOT);

Intent action2Intent = new Intent(PSLocationService.this, NotificationActionService.class)
.setAction("settings").putExtra("settings", "settings");
PendingIntent action2PendingIntent = PendingIntent.getService(PSLocationService.this, 1,
action2Intent, PendingIntent.FLAG_ONE_SHOT);

RemoteInput remoteInput = new RemoteInput.Builder("autopilot")
.setLabel("Stop")
.build();
NotificationCompat.Action action1 =
new NotificationCompat.Action.Builder(R.drawable.icn_terms_settings,
"Stop", action1PendingIntent)
.addRemoteInput(remoteInput)
.build();

RemoteInput remoteInput2 = new RemoteInput.Builder("settings")
.setLabel("Settings")
.build();
NotificationCompat.Action action2 =
new NotificationCompat.Action.Builder(R.drawable.icn_terms_settings,
"Settings", action2PendingIntent)
.addRemoteInput(remoteInput2)
.build();
mBuilder.addAction(action1);
mBuilder.addAction(action2);
}
Notification notification = mBuilder.build();
startForeground(1338, notification);

但每当我按下通知时,我都会收到此错误:

12-15 17:35:06.553: D/StatusBar(933): Clicked on button 0 for 0|nl.hgrams.passenger|1338|null|12567
12-15 17:35:06.555: E/RemoteViews(933): Cannot send pending intent:
12-15 17:35:06.555: E/RemoteViews(933): android.content.IntentSender$SendIntentException
12-15 17:35:06.555: E/RemoteViews(933): at android.app.ContextImpl.startIntentSender(ContextImpl.java:753)
12-15 17:35:06.555: E/RemoteViews(933): at android.content.ContextWrapper.startIntentSender(ContextWrapper.java:390)
12-15 17:35:06.555: E/RemoteViews(933): at android.content.ContextWrapper.startIntentSender(ContextWrapper.java:390)
12-15 17:35:06.555: E/RemoteViews(933): at android.widget.RemoteViews$OnClickHandler.onClickHandler(RemoteViews.java:217)
12-15 17:35:06.555: E/RemoteViews(933): at com.android.systemui.statusbar.BaseStatusBar$3.onClickHandler(BaseStatusBar.java:323)
12-15 17:35:06.555: E/RemoteViews(933): at android.widget.RemoteViews$SetOnClickPendingIntent$1.onClick(RemoteViews.java:720)
12-15 17:35:06.555: E/RemoteViews(933): at android.view.View.performClick(View.java:5204)
12-15 17:35:06.555: E/RemoteViews(933): at android.view.View$PerformClick.run(View.java:21153)
12-15 17:35:06.555: E/RemoteViews(933): at android.os.Handler.handleCallback(Handler.java:739)
12-15 17:35:06.555: E/RemoteViews(933): at android.os.Handler.dispatchMessage(Handler.java:95)
12-15 17:35:06.555: E/RemoteViews(933): at android.os.Looper.loop(Looper.java:148)
12-15 17:35:06.555: E/RemoteViews(933): at android.app.ActivityThread.main(ActivityThread.java:5417)
12-15 17:35:06.555: E/RemoteViews(933): at java.lang.reflect.Method.invoke(Native Method)
12-15 17:35:06.555: E/RemoteViews(933): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
12-15 17:35:06.555: E/RemoteViews(933): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

最佳答案

FLAG_ONE_SHOT 更改为 FLAG_UPDATE_CURRENT 使其正常工作

关于android - 通知中的操作不执行任何操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47836447/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com