我认为
Android 8.0中的抬头通知禁用,但即使在运行Android 8.0时,android的内置消息也具有此功能.
我知道如何通过设置振动通知来显示低于8.0设备的抬头通知.但是,运行Oreo的通知上的振动已被弃用.所以我去互联网搜索,有人说启用setVibrationPattern到通知通道将起作用.但遗憾的是,这不起作用.
我知道如何通过设置振动通知来显示低于8.0设备的抬头通知.但是,运行Oreo的通知上的振动已被弃用.所以我去互联网搜索,有人说启用setVibrationPattern到通知通道将起作用.但遗憾的是,这不起作用.
所以这是我的代码.
Notification builder = new NotificationCompat.Builder(MainActivity.this) .setAutoCancel(true) .setWhen(System.currentTimeMillis()) .setSmallIcon(R.drawable.ic_android_black_24dp) .setChannelId(id) .setPriority(Notification.PRIORITY_HIGH) .setColor(setActionColor(counter)) .setColorized(true) .setContentIntent(pendingIntent) .build(); //Notification channel code. NotificationChannel chan2 = new NotificationChannel(SECONDARY_CHANNEL,getString(R.string.noti_channel_second),NotificationManager.IMPORTANCE_HIGH); chan2.setLightColor(Color.BLUE); chan2.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC); manager.createNotificationChannel(chan2); manager.notify(notificationID,builder);
解决方法
您还需要将“设置”中的应用程序通知设置设置为“紧急”.除非用户将应用程序设置为紧急,否则不会显示抬头通知.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。