1

私のアプリケーションでは、6.0より下では動作しますが、6.0より上のデバイスでは、動作ボタンがクリックされず、通知全体がクリックされ、コンテンツの意図が代わりにアクションボタンが意図的に保留中である場合、誰かがマーズハムロー以上のアクションボタンの使用方法を知っていますか?MarshmallowのAndroidの通知の問題

以下

が私のコードです: -

Intent downloadCancel = new Intent(); 
    downloadCancel.setAction("CANCEL"); 
    PendingIntent cancelPI = PendingIntent.getBroadcast(this,1,downloadCancel, 0); 

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) 
    { 
     Notification.Action actionButton = new Notification.Action.Builder(android.R.drawable.ic_menu_close_clear_cancel,"Cancel",cancelPI).build(); 
     notification = new Notification.Builder(this) 
       .setContentTitle(title) 
       .setContentText(text) 
       .setSmallIcon(R.drawable.ic_file_download_white_24dp) 
       .setContentIntent(pendingIntent) 
       .setTicker(text) 
       .setWhen(0) 
       .setPriority(Notification.PRIORITY_MAX) 
       .addAction(actionButton).getNotification(); 
    } 
    else 
    { 
     notification = new Notification.Builder(this) 
       .setContentTitle(title) 
       .setContentText(text) 
       .setSmallIcon(R.drawable.ic_file_download_white_24dp) 
       .setContentIntent(pendingIntent) 
       .setTicker(text) 
       .setWhen(0) 
       .setPriority(Notification.PRIORITY_MAX) 
       .addAction(android.R.drawable.ic_menu_close_clear_cancel, "Cancel", cancelPI).getNotification(); 
    } 

答えて

0

私は、この問題のために他のオプションをremoteViewsを使用しないために持っていた

0

使用

NotificationCompat.Action action = new NotificationCompat.Action.Builder(R.drawable.ic_menu_close_clear_cancel, "Cancel", cancelPI).build(); 

代わりの

Notification.Action actionButton = new Notification.Action.Builder(android.R.drawable.ic_menu_close_clear_cancel,"Cancel",cancelPI).build(); 
+0

がありました私はこれを使用してみましたが、それを表示addAction()行でNotification.Actionの代わりにNotificationCompat.Actionを使用できないというエラーが発生しました。 – Akki