I am trying to open an activity from a class that extends Service. I am performing this task when the app is not in foreground/not being used. I can see in the logs that my service class triggered start activity with Intent.FLAG_ACTIVITY_NEW_TASK flag. But the activity does not open. But when the service triggers the same activity when the app is in foreground/being used, the activity opens.
After few searches I found out that I need to manually give the permission "display popup windows while running in the background android" in the other permissions section in the app settings.
The display over other apps permission SYSTEM_ALERT_WINDOW only gives access to "Display popup window".
In the image above, SYSTEM_ALERT_WINDOW will only grant you access to "Display popup window" and this works fine if the app is in foreground/being used but the permission marked in red if granted will give you access to open any activity directly from a class extending Service.
How do I check or ask the user to give "Display popup windows while running in the background" permission? or Is this permission restricted?
I see apps like Whatsapp have this checked by default.