Reputation: 1833
In Android there is an option to choose how notifications will show on the lock screen:
In phones that run stock Android OS the lock screen preferences are global for all the apps. But in Xiaomi it is possible to configure these preferences for each app.
Is there a way I can programmatically find out from my android app if the user selected to opt out from notifications on lock screen?
Upvotes: 2
Views: 985
Reputation: 47985
I am not sure if this works on all Android versions, but this works for me:
fun getLockscreenNotificationsEnabled(context: Context) =
android.provider.Settings.Secure.getInt(
context.contentResolver,
"lock_screen_show_notifications", 0
) != 0
Upvotes: 1