在Android L上,我想在用户设置设置为“显示所有通知内容”时向用户显示锁定屏幕上的通知,否则内容将毫无意义,我只是不想显示通知.
知道如何在代码中验证用户通知设置吗?
谢谢!
解决方法:
你需要阅读
Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS = "lock_screen_allow_private_notifications"
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS = "lock_screen_show_notifications"
只有两者都是1,那么你需要显示你的通知.
但由于这些值不属于公共API,因此将来可能会发生变化,或者可能无法在所有设备上运行
int show_all = Settings.Secure.getInt(getContentResolver(),"lock_screen_allow_private_notifications", -1);
int noti_enabled = Settings.Secure.getInt(getContentResolver(),"lock_screen_show_notifications", -1);
if(show_all > 0 && noti_enabled > 0){
//post noti
}
标签:android,android-5-0-lollipop
来源: https://codeday.me/bug/20190624/1276044.html