Android Question How to check PERMISSION_ACCESS_BACKGROUND_LOCATION in runtimepermissions

Hi. I am trying to check if the application has permission to access the location all the time. But with runtimepermissions I did not find a way to check if the permission for location in background is allowed or not (that is, if the user selected to allow only with the app in use or to allow all the time).

I would like to know if there is another way to perform this check.

Greetings and thank you very much


Well-Known Member
Licensed User
Yes, a friend informed me of this new conditional permission for location tracking on his Android 10 phone.

I don't know of a way of programmically detecting if the user selected "All the time" or "Just when app in use" when they answered the location permission pop-up for your app. But maybe this workaround might work for you...

When your app first asks for permission and the user gives it, record that fact.

Then before your app tries to capture a location in the background, do a permission check again and if it comes back denied this time (but they did approve it the first time your app ran above), then I think it would be safe to assume the user chose "Allow Location only when app is in use" when they first granted permission.
Last edited:
The example work perfectly, but if the user select "allow all the time" when the app require the permission. If the user select "only when the user select allow only with the app in use, the GPS_LocationChanged didnt give me the new locations.


Thank you for your time!


Erel thank you very much, you are incredible. I have been looking for software like yours for a long time, and on top of it with incredible support. You really do a very good job, thanks again
I still having problems when the phone is locked. But i try with the two options (Only available when app is running and all the time), and the problem is the same.

Mayble could be a problem with PhoneWakeState?

Thank you for your time and sorry for a lot of questions.

I am testing, and the problem was with the Phone battery mode.

If it was in medium battery saving (even though the optimized battery used in the app was disable), the GPS didn't work when the screen is OFF.

Is there any way to solve it?

Thank you again and sorry for my bad english