Android-уведомления не работают в huawei
В оборудовании Huawei, как подать заявку на разрешение баннерных уведомлений, он по умолчанию отключен.
Я сделал следующие настройки, которые работали только тогда, когда я вручную включил баннерные уведомления.
Как решить?
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
String channelId = "007";
String channelName = "James Bond";
NotificationChannel notificationChannel = new NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_MAX);
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.createNotificationChannel(notificationChannel);
Intent notificationIntent = new Intent();
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(getApplication(), 0, notificationIntent, 0);
Notification notification = new NotificationCompat.Builder(MainActivity.this, "007")
.setPriority(NotificationCompat.PRIORITY_MAX)
.setContentTitle("What is 5G ?")
.setContentText("But before we get to the smart phones, let's simply figure out what 5G is.")
.setWhen(System.currentTimeMillis())
.setSmallIcon(R.drawable.ic_launcher_background)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher_background))
.setDefaults(Notification.DEFAULT_VIBRATE)
.setAutoCancel(true)
.setVibrate(new long[0])
//.setFullScreenIntent(pendingIntent, true)
.build();
notificationManager.notify(1, notification);
}
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.ACCESS_NOTIFICATION_POLICY" />
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />