简体   繁体   中英

How can i check lock screen notifcation is enabled or not programmatically

I want to check that user has enabled lock screen notifications or not. Settings -> Notifications -> Lock Screen Notifications

But I am not able to find any code regarding this.

Try this:

fun getLockscreenNotificationsEnabled(context: Context) =
    android.provider.Settings.Secure.getInt(
        context.contentResolver,
        "lock_screen_show_notifications", 0
    ) != 0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM