Я пытаюсь создать пользовательский макет уведомления с опцией встроенного ответа.Но ответное действие не отображается в уведомлении.Тем не менее, то же самое отлично работает с представлением уведомлений по умолчанию.
android.app.Notification.Builder notificationBuilder = new android.app.Notification.Builder(context, Constants.CHANNEL_ONE_ID)
.setSmallIcon(R.drawable.ic_notification)
.setLargeIcon(getBitmap(userId, getAvatarText(userId)))
.setSound(defaultSoundUri)
.setVibrate(pattern)
.setAutoCancel(true)
.setDeleteIntent(deleteIntent);
RemoteViews collapsedView = new RemoteViews(getPackageName(), R.layout.view_collapsed_notification);
String replyLabel = "Reply";
android.app.RemoteInput remoteInput = new android.app.RemoteInput.Builder(KEY_TEXT_REPLY)
.setLabel(replyLabel)
.build();
android.app.Notification.Action action = new android.app.Notification.Action.Builder
(Icon.createWithResource(WorkspaceApp.getInstance(), android.R.drawable.sym_action_chat), "Reply", pendingIntent)
.addRemoteInput(remoteInput)
.build();
notificationBuilder.setCustomContentView(collapsedView);
notificationBuilder.addAction(action);
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
//notificationBuilder.addAction(action);
notificationManager.notify(notifId, notificationBuilder.build());
R.layout.view_collapsed_notification используется для свернутого просмотра.Который содержит заголовок, содержание и изображение.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_10"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toStartOf="@+id/avatar"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:fontFamily="sans-serif-medium"
android:textSize="15dp"
android:textStyle="normal"
android:textColor="@android:color/black"
tools:text="Raksha User" />
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:textSize="14dp"
tools:text="Raksha User" />
</LinearLayout>
<ImageView
android:id="@+id/avatar"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_gravity="center_vertical"
android:layout_marginEnd="8dp"
android:src="@drawable/smiley_thumb" /> </LinearLayout></LinearLayout>
Заранее спасибо.