在 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 时,您才需要显示您的通知。 但是由于这些值不是公共(public) 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 用户的 "when device is locked"通知设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27768345/