#android #notifications
Вопрос:
Уведомление исчезает, как и планировалось, но желаемое действие не запускается. Действие экрана пробуждения должно быть запущено. Он безупречно работает на устройстве с Android 10. к сожалению, не с Android 11.
Вот мой код:
NotificationManager notificationManager = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);
Intent intent = new Intent(context,WakeUpScreen.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK|Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
NotificationChannel channel = new NotificationChannel(context.getResources().getString(R.string.PRIORITAET_LOW_STRING), context.getResources().getString(R.string.PRIORITAET_LOW_STRING), NotificationManager.IMPORTANCE_HIGH);
if (notificationManager != null) {
notificationManager.createNotificationChannel(channel);
}
NotificationCompat.Builder notification = new NotificationCompat.Builder(context, context.getResources().getString(R.string.PRIORITAET_LOW_STRING))
.setContentTitle(context.getResources().getString(R.string.PRIORITAET_LOW_STRING))
.setAutoCancel(true)
.setContentIntent(pendingIntent)
.setGroup(context.getResources().getString(R.string.PRIORITAET_LOW_STRING))
.setContentText(nachricht.getTextNachricht())
.setLights(Color.WHITE,1000,1000)
.setOngoing(true)
.setSmallIcon(R.mipmap.ic_launcher_round);
if (notificationManager != null) {
notificationManager.notify(1, notification.build());
return true;
}
Пожалуйста, помогите мне
Комментарии:
1. Я протестировал ваш код на Samsung M51 с Android 11, и он работает для меня. Видите ли вы что-нибудь в журналах студии, когда нажимаете на уведомление, или что-нибудь необычное?