Man*_*ish 5 notifications android android-8.0-oreo
我创建通知通道,以在Android 8.0中显示通知,如下所示
NotificationChannel uploadChannel = new NotificationChannel(Constants.NOTIFICATION_CHANNEL_UPLOAD_ID,"Uploads", NotificationManager.IMPORTANCE_LOW);
uploadChannel.enableLights(false);
uploadChannel.setDescription("Uploads Channel");
notificationManager.createNotificationChannel(uploadChannel);
Run Code Online (Sandbox Code Playgroud)
每当我显示通知手机振动很多次.我从通知通道禁用振动,如下所示
uploadChannel.enableVibration(false);
Run Code Online (Sandbox Code Playgroud)
我创建如下通知
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context, Constants.NOTIFICATION_CHANNEL_UPLOAD_ID);
Run Code Online (Sandbox Code Playgroud)
但它不工作电话随着每个通知振动.
小智 18
这是Android 8通知系统上的一个错误.我修修补补用不同的组合enableVibration有setVibrationPattern(null),但它不工作.
只有阻止振动的解决方案是:
mNotificationChannel.setVibrationPattern(new long[]{ 0 });
mNotificationChannel.enableVibration(true);
Run Code Online (Sandbox Code Playgroud)
仅供参考,即使我将振动模式设置enableVibration为0,但设置为振动模式false,它也会振动.
Rol*_*den 17
除了Ahmadul Hoq的答案,这对我有用之外,我想补充一点,你可能需要删除应用程序并在振动发生变化之前重新安装它.如果应用程序被终止,通道会保持其初始设置并保持活动状态 - 因此,如果您只是构建并运行,则可能无法应用更改.
| 归档时间: |
|
| 查看次数: |
5904 次 |
| 最近记录: |