• QQ
  • nahooten@sina.com
  • 常州市九洲新世界花苑15-2

Android

android 通知(关闭声音和震动)

原创内容,转载请注明原文网址:http://homeqin.cn/a/wenzhangboke/jishutiandi/Android/2019/0614/539.html


​8.0版本以下

 

//单个设置

mBuilder.setVibrate(null);

mBuilder.setVibrate(new long[]{0l})

mBuilder.setSound(null);

mBuilder.setLights(0, 0, 0);

//默认全部

mBuilder.setDefaults(Notification.DEFAULT_ALL);

按上面代码,实测锤子5.1系统还是会有声音

 

 mBuilder.setDefaults(NotificationCompat.FLAG_ONLY_ALERT_ONCE);//统一消除声音和震动

8.0版本

 

//需要在创建CHANNEL时确定

NotificationManager.IMPORTANCE_MIN: 静默;

NotificationManager.IMPORTANCE_HIGH:随系统使用声音或振动 

 

notificationChannel = new NotificationChannel(CHANNEL_ONE_ID,

                    CHANNEL_ONE_NAME, NotificationManager.IMPORTANCE_MIN);

 

上篇:上一篇:办理安卓打包apk安置后翻开闪退的问题
下篇:下一篇:修改ro属性的小工具新版本-170119