Я пытаюсь создать собственное сообщение и во всех ситуациях, которые оно создает. Дизайн создается только после того, как сообщение попадает в ветку уведомлений Android, но в первые моменты, прежде чем оно попадет туда и отобразится в передней части экрана, сообщение отображается в соответствии с УВЕДОМЛЕНИЕМ ANDROID по умолчанию, есть ли решение создать и изменить НАЗВАНИЕ и ТЕКСТ сообщения, даже если оно находится в передней части экрана, или изменить настройки по умолчанию?
Это мой код: custom_notification.xml
Это мой Java-код:
private void showCustomNotification(Context context, String title, String message) {
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
String channelId = "custom_channel_id";
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(channelId, "Custom Notifications", NotificationManager.IMPORTANCE_HIGH);
notificationManager.createNotificationChannel(channel);
}
RemoteViews customView = new RemoteViews(context.getPackageName(), R.layout.custom_notification);
customView.setTextViewText(R.id.custom_title, title);
customView.setTextViewText(R.id.custom_message, message);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, channelId)
.setSmallIcon(R.drawable.ic_notification)
.setCustomContentView(customView)
.setStyle(new NotificationCompat.DecoratedCustomViewStyle())
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setAutoCancel(true);
Intent intent = new Intent(context, YourActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(pendingIntent);
notificationManager.notify(1, builder.build());
}
Подробнее здесь: https://stackoverflow.com/questions/787 ... -android-s
Пользовательское уведомление не отображается при получении на передней части экрана ANDROID. ⇐ JAVA
Программисты JAVA общаются здесь
1720727893
Anonymous
Я пытаюсь создать собственное сообщение и во всех ситуациях, которые оно создает. Дизайн создается только после того, как сообщение попадает в ветку уведомлений Android, но в первые моменты, прежде чем оно попадет туда и отобразится в передней части экрана, сообщение отображается в соответствии с УВЕДОМЛЕНИЕМ ANDROID по умолчанию, есть ли решение создать и изменить НАЗВАНИЕ и ТЕКСТ сообщения, даже если оно находится в передней части экрана, или изменить настройки по умолчанию?
Это мой код: custom_notification.xml
Это мой Java-код:
private void showCustomNotification(Context context, String title, String message) {
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
String channelId = "custom_channel_id";
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(channelId, "Custom Notifications", NotificationManager.IMPORTANCE_HIGH);
notificationManager.createNotificationChannel(channel);
}
RemoteViews customView = new RemoteViews(context.getPackageName(), R.layout.custom_notification);
customView.setTextViewText(R.id.custom_title, title);
customView.setTextViewText(R.id.custom_message, message);
NotificationCompat.Builder builder = new NotificationCompat.Builder(context, channelId)
.setSmallIcon(R.drawable.ic_notification)
.setCustomContentView(customView)
.setStyle(new NotificationCompat.DecoratedCustomViewStyle())
.setPriority(NotificationCompat.PRIORITY_HIGH)
.setAutoCancel(true);
Intent intent = new Intent(context, YourActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(pendingIntent);
notificationManager.notify(1, builder.build());
}
Подробнее здесь: [url]https://stackoverflow.com/questions/78737459/custom-notification-is-not-displayed-when-received-on-the-front-of-the-android-s[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия