Can I find out when / if a user has disabled "background activity" in API Level 26 (Oreo)?

I do not aim at 26, but I want to know when the user turned off "background activity", as described in the documentation (until show notification when this happens).

Are there any intentions that I can listen to? or any other way to programmatically find out if it is currently disabled?

+4
source share
1 answer

I managed to find a way to find out if the user turned off the "background action". Not sure if this is the best solution, but it seems like it works:

onDestroy ( JobScheduler) .

, , . , :

ComponentName componentName = startService(serviceIntent);
if(componentName == null){
    // we could not start the service, so user probably disabled the background activity
}
0

Source: https://habr.com/ru/post/1685005/


All Articles