Android API 23 で大きい/拡張されたカスタム通知を表示しようとしていますが、アクション ボタンが表示されません。
あなたは私のコードを見つけることができます。アクションも追加しようとしましたが、成功しませんでした。
他の質問からの他の回答も試しましたが、うまくいきませんでした。
これが私のコードです:
Notification.Builder mBuilder =
new Notification.Builder(this)
.setSmallIcon(R.drawable.mailunread)
.setContentTitle("My notification")
.setContentText("Hello World!").setWhen(0);
Notification notification = mBuilder.build();
RemoteViews contentView=new RemoteViews(this.getPackageName(), R.layout.cell_notification);
notification.bigContentView = contentView;
NotificationManager mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(1, notification);
そして、ここに私の見解があります:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="New offer for search" android:textColor="@android:color/black" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content" android:text="vendor" android:textColor="@android:color/black" />
<ImageView
android:layout_width="100dp" android:layout_gravity="center"
android:layout_height="wrap_content" android:src="@drawable/iphone1"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content" android:text="elevator pitch" android:textColor="@android:color/black" />
<Button
android:id="@+id/buttonNotification"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Respond Now"
android:textColor="@android:color/black"
android:layout_weight="20"/>
</LinearLayout>