2017-04-16 68 views
0

在Android上,您在通知下设置了“锁定屏幕上的控制通知”设置,并且支持您设置通知的可见性,如notification Tutorial中所述。获取设置状态:“锁定屏幕上的控制通知”

那么我的queston是否可以得到这个设置的状态?

我想设置状态的原因是为用户提供更多选项,如果他们启用了内容隐藏功能,但是如果他们没有启用内容隐藏功能,则不会打扰他们。

回答

0

是的,这是可能的。有两个常量:

Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS = "lock_screen_allow_private_notifications" 
Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS = "lock_screen_show_notifications" 

然而,由于这些值是不公开的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 notification 
    // ... 
} 
相关问题