On Android L, I would like to show the user a notification on the lock screen only if the user’s settings are set to “show all notification content”, otherwise the content will be meaningless, and I just prefer not to show the notification at all.
Any idea how to check custom notification settings in the code?
Thank!
You need to read
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 }
, , , , . , setVisibility() (Notification.Builder.setVisibility) :
setVisibility()
Notification.Builder.setVisibility
VISIBILITY_PUBLIC: .
VISIBILITY_PUBLIC
VISIBILITY_PRIVATE: , , .
VISIBILITY_PRIVATE
VISIBILITY_SECRET: , .
VISIBILITY_SECRET
VISIBILITY_PRIVATE, , . , SMS , " 3 ", . , , Notification.Builder. , setPublicVersion().
Notification.Builder
setPublicVersion()
Source: https://habr.com/ru/post/1569903/More articles:How to replace multiple values in php - phpWhy is the canvas painted with a slightly different color than the image itself? - javascriptHow can I list and print files in a directory? - powershellHow to create a dependent common protocol in fast - genericsНеобычное преобразование между float и long - cThe first width search does not return the shortest path - javaОшибка Tesseract при тривиальном входном изображении. Ошибка Segfault - pythonHow to correctly get accelerometer data using Swift in iOS? - iosC ++ 11 Atomic Container Thread Security - multithreadingjava.io.NotSerializableException: java.util.HashMap $ Node - javaAll Articles