Wish Update RuntimePermissions with constant for ACCESS_BACKGROUND_LOCATION

Sandman

Expert
Licensed User
Longtime User
(Background post)

It seems that we need to request permission ACCESS_BACKGROUND_LOCATION when we want to access background location. This constant isn't available in RuntimePermissions, would be nice if it could be added.

Note: as one can see in the linked background post, I'm very unsure about things here. But I suspect we still would need this permission.
 

roumei

Active Member
Licensed User
From my understanding, ACCESS_BACKGROUND_LOCATION is considered a 'dangerous' permission and needs to be defined in the manifest. I don't think it's possible to use it via RuntimePermissions. Google handles background location access more and more restrictively in API29+. I had to fill in a form and explain the usage of background location in detail and upload a video to demonstrate how the apps asks for the permission. I think, Google uses ACCESS_BACKGROUND_LOCATION in the manifest to filter out apps that need to go through this process. The foregroundServiceType "location" also seems to trigger this.
 

Sandman

Expert
Licensed User
Longtime User
Very interesting!

So, to be clear, you do have an app that uses the built-in geofences?

And you've set target API to 29 or higher?

Do you use a foreground service?

Do you only have ACCESS_BACKGROUND_LOCATION in the manifest, and also was approved by Google? So no RuntimePermissions? Meaning: Does the user at any point get a question with something like "do you want this app to get your location all the time?"

Where did you find the form to fill in? I'm looking in the console, and I can't seem to find it.


Sorry for the amount of questions, I'm just excited that somebody seem to have all the answers. :)
 

roumei

Active Member
Licensed User
No, sorry. I've got no experience with geofences. I only know about normal 'background location' (or rather the foregroundServiceType).
Yes, android:targetSdkVersion="29".
Yes, SetServiceAttribute(Tracker, android:foregroundServiceType, "location").
No, I don't have an ACCESS_BACKGROUND_LOCATION in the manifest but using the foregroundServiceType:location is still considered 'background location' by Google.
I only request rp.PERMISSION_ACCESS_FINE_LOCATION and there's only the 'When in use' option.
If Google detects some kind of background location, you'll get a notification. The form can be found here:
PermissionsDeclarationForm.JPG
 

OliverA

Expert
Licensed User
Longtime User
From my understanding, ACCESS_BACKGROUND_LOCATION is considered a 'dangerous' permission and needs to be defined in the manifest. I don't think it's possible to use it via RuntimePermissions.
According to Google docs, as of API 29, ACCESS_BACKGROUND_LOCATION must be declared in the Manifest and must be requested during runtime (via runtime permissions) in order to use the Geofencing API.
On top of that, as of API 30, one may have to pop up an explanation screen as to why the app requests ACCESS_BACKGROUND_LOCATION (this popup may also be true for API 29, see links below)
Both are something that B4A must provide support for
Links:
 
Last edited:
Top