Detect if app is on "Never sleeping apps" list? And request that app is added to that list?


Is there an API which can be called from within an app to figure out whether the it is on the “Never sleeping apps” list?

Also, is there a way from within an app to request to be added to the “Never sleeping apps” list? - or alternatively to launch the settings page for “Never sleeping apps”?

I am working on an app which in some circumstances need to perform continuous iBeacon monitoring in the background (in context of a foreground service) and it would be really helpful to be able to figure out whether the app is configured as “never sleeping” which is required for the iBeacon monitoring to keep working.

Google provides an API for checking the app’s App-Restriction state,

To check power save mode state, use below API

To be excluded from the App-Restriction target, the app needs to get user-approval for being “Doze-whitelisted”.
You may check the document below :

This might be also helpful for you android - How do I properly fire ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS intent? - Stack Overflow

Also please check Acceptable use cases for whitelisting below,

Thanks for your reply! I am already using these APIs to detect whether Android background restrictions apply and also the global “Power Save Mode” state, and I’m also using the ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS intent.

My problem is that Samsung has it’s own separate power saving mechanism - the concept of “Sleeping Apps” - and I need tools (similar to those you mention for Android doze mode) for querying the app’s sleeping configuration/state as well as a way to request to be added to the “Never sleeping apps” list.

Since P-OS, google introduced Battery saving features. 3rd party applications now can be restricted by a user or by OEM’s own app restrictions such as the “App Sleeping” feature. As far as I know Samsung does not offer any special API for this case. You have to work with the Google’s APIs.