0

하지 않습니다 :액션이 내 코드입니다 아무것도

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) 
+0

'PendingIntent.getBroadcast()'는 어떻습니까? –

+0

죄송합니다. 문제를 해결하기 전에 해결해야 할 큰 문제가 있습니다. PendintInteng.getBroadcast는 객체를 반환합니다. 'pending intent 2 is : PendingIntent {f31c8fa : [email protected]}' –

답변

0

그것이

작동 원인 FLAG_UPDATE_CURRENTFLAG_ONE_SHOT을 변경을