Я пытаюсь создать пользовательский вид уведомления, но он не работает
Ниже приведен код:
RemoteViews contentView=new RemoteViews(getPackageName(), R.layout.my_notification_layout);
NotificationCompat.Builder mBuilder= new NotificationCompat.Builder(SplashScreenActivity.this, "DEFAULT_CHANNEL_MYAPP")
.setCustomContentView(contentView)
.setCustomBigContentView(contentView);
mBuilder.setContentIntent(pendingIntent);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mBuilder.setSmallIcon(R.drawable.app_icon_white);
mBuilder.setColor(getResources().getColor(R.color.theme_color));
} else {
mBuilder.setSmallIcon(R.drawable.app_icon_white);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
CharSequence name = getResources().getString(R.string.feroz_channel_name);
String description = getResources().getString(R.string.feroz_channel_description);
int importance = NotificationManager.IMPORTANCE_DEFAULT;
NotificationChannel channel = new NotificationChannel("DEFAULT_CHANNEL_MYAPP", name, importance);
channel.enableLights(true);
channel.setLightColor(getResources().getColor(R.color.theme_color));
channel.enableVibration(true);
channel.setDescription(description);
NotificationManager notificationManager1 = getSystemService(NotificationManager.class);
notificationManager1.createNotificationChannel(channel);
}
NotificationManager notificationManager1 = getSystemService(NotificationManager.class);
notificationManager1.notify(11132,mBuilder.build());
Ниже приведен пользовательский макет уведомления
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginLeft="32dp"
android:layout_marginTop="16dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:src="@mipmap/ic_launcher" />
<TextView
android:id="@+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:text="My APP"
android:textSize="24sp"
android:textColor="@color/greyishBrown"
app:layout_constraintBottom_toBottomOf="@+id/imageView9"
app:layout_constraintStart_toEndOf="@+id/imageView9"
app:layout_constraintTop_toTopOf="@+id/imageView9" />
</RelativeLayout>
Я пытаюсь это в Android 10 версии. Уведомление не отображается