2017-01-31 25 views
3

このようなアンドロイド通知をカスタマイズしようとしています。アンドロイド通知でアクションボタンが表示されない

enter image description here

すべてが上記API23のために正常に動作します。下記のAPI23のアクションボタンは表示されません。私は自分のコードに何が間違っているのか分かりません。ここ

はAPI23以下のための私のサンプルコードです:

RemoteViews expandedView = createMultiRemoteViews(context, 
       R.layout.notification_multiview_b23, icon, "Custom notification", "This is a custom layout", leftImage, rightImage, "09:10", "16:23"); 

expandedView.setOnClickPendingIntent(R.id.left_image, leftImageIntent); 
expandedView.setOnClickPendingIntent(R.id.right_image, rightImageIntent); 

NotificationCompat.Action addToWatchListAction = new NotificationCompat.Action.Builder(R.drawable.ic_bookmark_border_black_24dp, 
       LABEL_ADD_TO_WATCH_LIST, addToWatchList).build(); 

NotificationCompat.Builder builder = createNotificationBuider(context, "Custom notification", "This is a custom layout", icon); 
builder.addAction(addToWatchListAction); 
builder.setCustomBigContentView(expandedView); 

showNotification(context, builder.build(), MULTI_NOTI_ID); 
+0

アンドロイド版を試してみましたか? [NotificationCompat.Action official doc](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Action.html)は、Android 4.1以前は動作しないと言いました – rala

+0

@rala試しましたAndroidバージョン6.0.1 私のminSDKバージョンは16です。 –

答えて

0

通知アクションは、API 24以下は利用できませんこれは、互換性の問題かもしれません。下位互換性をサポートするには、サポートライブラリのNotificationComaptクラスを使用します。 公式ドキュメントにはa link、サポートライブラリクラスにはa linkのリンクがあります。

+0

私はNotificationCompactクラスを使用しました。 –

+0

@khaleel_jageer "特定のバージョンの通知機能は、サポートライブラリクラスNotificationCompat.Builderに設定されていても使用できません。たとえば、拡張された通知に依存するアクションボタンはAndroid 4.1にのみ表示されます拡張された通知自体はAndroid 4.1以上でのみ利用可能であるため、これ以上です。 https://developer.android.com/guide/topics/ui/notifiers/notifications.html#Compatibility –

関連する問題