pendingIntent = PendingIntent.getActivity
(getApplicationContext(),0,intent, PendingIntent.FLAG_MUTABLE);
}
else
{
pendingIntent = PendingIntent.getActivity(getApplicationContext(),0,intent, PendingIntent.FLAG_UPDATE_CURRENT);
}
.
.
.
String channelId = getString(R.string.default_notification_channel_id);
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(this, channelId)
.setSmallIcon(iconId)
.setPriority(NotificationManager.IMPORTANCE_HIGH)
.setDefaults(Notification.DEFAULT_LIGHTS )
.setSound(null)
.setVibrate(new long[]{0, 500, 1000, 500, 200, 400, 100, 400, 600})
.setContentIntent(pendingIntent);
notificationBuilder.setColor(Color.parseColor("#FF9933"));
notificationBuilder.setChannelId(channelId);
notificationBuilder.setAutoCancel(false);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.S) {
.
.
.
notificationBuilder.setCustomBigContentView(contentView);
notificationBuilder.setCustomHeadsUpContentView(contentView);
NotificationUpdater.turnOnForeground(this,notifId,notificationManager, notificationBuilder.build());
}
else
{
notificationBuilder.setContent(contentView);
notificationBuilder.setOngoing(true);
NotificationUpdater.turnOnForeground(this,notifId,notificationManager, notificationBuilder.build());
}
}
[/code]
my_notification_layout.xml
Код: Выделить всё
Подробнее здесь: https://stackoverflow.com/questions/793 ... android-14
Мобильная версия