当设备被锁定&QUOT

当设备被锁定&QUOT

本文介绍了检查Android用户"当设备被锁定"通知设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android的L,我想向用户显示只有当用户设置为显示所有通知内容,否则内容将是毫无意义的,我只是preFER不显示锁定屏幕上的通知通知都没有。

On Android L, I would like show the user a notification on the lock screen only if the user settings is set to "show all notification content", otherwise the content will be pointless and I just prefer not to show the notification at all.

不知道如何在code用户通知设置验证?

Any idea how to verify in code the user notification settings?

谢谢!

推荐答案

您需要阅读

Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS = "lock_screen_allow_private_notifications"

Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS = "lock_screen_show_notifications"

只有都为1,那么你需要出示您的通知。
但由于这些值是不是公共API的一部分,这些可能在将来改变,也可能不会在所有设备上工作。

only if both are 1 then you need to show your notifications.But since these values are not part of public api, these might change in future, or might not work on all devices

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用户"当设备被锁定"通知设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 02:00