Android Question FusedLocationProvider requesting location in the background

yo3ggx

Active Member
Licensed User
Longtime User
Today Google decided to remove one of my applications from Play Store for the following reason:
"Your app requests location in the background for either unapproved and/or undisclosed purposes. Apps that request location in the background must successfully complete a console-based declaration process and adequately disclose use to users."

I'm using FusedLocationProvider for a few years already to get location information in order to calculate distance to my correspondent during a ham radio call.
Any recommendation on how to prevent this mechanism working in the background?

Thank you.
 

JohnC

Expert
Licensed User
Longtime User
If you don't need to obtain the user's location in the background, then remove that ability from your app.

But if you need background location tracking, then you need to do two things:

1) Log into your google developer account and look for a way to "successfully complete a console-based declaration process" which will probably be some form you need to fill out to explain to google why you need background location access.
2) You need to display something in the app (when the user gives permission for background location) and describe in detail why you need background location permission.
 
Upvote 0

yo3ggx

Active Member
Licensed User
Longtime User
If you don't need to obtain the user's location in the background, then remove that ability from your app.
How to do this?
I have the following in Activity_Pause.
B4X:
If FusedLocationProvider1.IsInitialized And FusedLocationProvider1.IsConnected Then FusedLocationProvider1.Disconnect
But seems not to be enough.

But if you need background location tracking, then you need to do two things:

1) Log into your google developer account and look for a way to "successfully complete a console-based declaration process" which will probably be some form you need to fill out to explain to google why you need background location access.
I've tried this several times, but Google didn't accepted my explanation (rejected each time) and finally removed the application today.
2) You need to display something in the app (when the user gives permission for background location) and describe in detail why you need background location permission.
The user is never asked for background location permission, as I my application does not require this.
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
1) See if there is any entries in the manifest that are requesting background permission
2) If you have any code related to the fused-location lib in a "service", then move all of that code into an "activity" so that it is impossible for it to run in the background (because services can run in the background).
 
Upvote 0

yo3ggx

Active Member
Licensed User
Longtime User
1) See if there is any entries in the manifest that are requesting background permission
Nothing in the manifest file related to FusedLocation.
2) If you have any code related to the fused-location lib in a "service", then move all of that code into an "activity" so that it is impossible for it to run in the background (because services can run in the background).
All the code containing FusedLocation is in the Main module, nothing in the services.
 
Upvote 0

yo3ggx

Active Member
Licensed User
Longtime User
Another interesting thing is that the app was published in two versions: one free, with some limitations and a Pro version. All the code related to FusedLocation is identical in both version (double checked again today) , but only the Pro version was removed by Google. I'm totally confused.
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Another interesting thing is that the app was published in two versions: one free, with some limitations and a Pro version. All the code related to FusedLocation is identical in both version (double checked again today) , but only the Pro version was removed by Google. I'm totally confused.
Hopefully their automated "scanner" won't find your free version :)
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
If you used example code on this forum for the fused-location code, please provide a link to the post the code came from.
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
After you compile your app, click the "List Permissions" button on the "Log" tab of the IDE and paste the contents of that dialog.

Also, when your app asks the user for location permission, does the pop-up dialog have three choices, with one because "Allow app to always access location"?
 
Upvote 0

yo3ggx

Active Member
Licensed User
Longtime User
After you compile your app, click the "List Permissions" button on the "Log" tab of the IDE and paste the contents of that dialog.
As I cannot copy everything, just a single line, this is the screenshot
permissions.png

Also, when your app asks the user for location permission, does the pop-up dialog have three choices, with one because "Allow app to always access location"?
Only "While using the app", "Only this time" and "Deny".
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
OK, there are a lot of permissions. And it looks like your app can receive intents (BroadCastReceiver, Access_Course_Updates, C2D_Message) which could "start" your app in the background and maybe that's causing the scanner to trip that warning.

Maybe force-removing some of the permissions related to receiving location-related intents (ie. via broadcastreceiver) might prevent these false scanner alerts:

(place these lines in the manifest)

B4X:
RemovePermission(android.permission.ACCESS_COURSE_UPDATES)
RemovePermission(android.permission.ACCESS_COURSE_LOCATION)

But I am just guessing here because I am running out of ideas.
 
Upvote 0

yo3ggx

Active Member
Licensed User
Longtime User
If I remove android.permission.ACCESS_COARSE_LOCATION some features related to location services does no more work and this permission can no more be requested in the app. Removed the other one with no side effects, but still don't know if this is enough. There is any way to check if location is still requested in the background?
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
The only other thing I can think of is that maybe one of the location components (google-service, GPS, Fused-Location) has the "capability" to track location in the background, even though your app does not try to do that, and that's whats triggering the google alerts.

In that case, maybe switching to another lib other then the fused-location might work.
 
Upvote 0

Omar Parra A.

Expert
Licensed User
Longtime User
this topic was said earlier, because google rejects background tracking.

see:
 
Last edited:
Upvote 0

yo3ggx

Active Member
Licensed User
Longtime User
.
this topic was said earlier, because google rejects background tracking.

see:
Checked the link, but there is stated:
"If you don't need location access in the background, remove it. If your app targets Android 10 (API level 29) or higher, remove the ACCESS_BACKGROUND_LOCATION permission from your app's manifest. When you remove this permission, all-the-time access to location isn't an option for the app on devices that run Android 10."

I don't have ACCESS_BACKGROUND_LOCATION in my manifest file at all. Is necessary to add this to the manifest file if I don't need background location?
B4X:
RemovePermission(android.permission.ACCESS_BACKGROUND_LOCATION)
 
Upvote 0

Omar Parra A.

Expert
Licensed User
Longtime User
you post:
Today Google decided to remove one of my applications from Play Store for the following reason:
"Your app requests location in the background for either unapproved and/or undisclosed purposes. Apps that request location in the background must successfully complete a console-based declaration process and adequately disclose use to users."

I'm using FusedLocationProvider for a few years already to get location information in order to calculate distance to my correspondent during a ham radio call.
Any recommendation on how to prevent this mechanism working in the background?

Thank you.

Google Solution:
read and see video:
All apps that access location in the background must be approved; otherwise, updates may be blocked and the app may be removed from Google Play.
 
Last edited:
Upvote 0

yo3ggx

Active Member
Licensed User
Longtime User
All apps that access location in the background must be approved; otherwise, updates may be blocked and the app may be removed from Google Play.

I think I was not very clear. My app does not need to access location in the background. My question was what is causing this as nothing in my code is specifically requesting this "dangerous" permission. I'm just using FusedLocationProvide library and requesting location services access for this purpose (nothing about background) and for Bluetooth discovery. And why two identical applications in the way location services are used (absolutely the same code) are treated differently by Google?

To resume, is enough to have the following in the manifest file to be sure that my app never request or use background location services?
B4X:
RemovePermission(android.permission.ACCESS_BACKGROUND_LOCATION)

I don't want to try by pushing the app to Play Store and to wait for a feedback from Google.
 
Upvote 0

Omar Parra A.

Expert
Licensed User
Longtime User
I think I was not very clear. My app does not need to access location in the background. My question was what is causing this as nothing in my code is specifically requesting this "dangerous" permission. I'm just using FusedLocationProvide library and requesting location services access for this purpose (nothing about background) and for Bluetooth discovery. And why two identical applications in the way location services are used (absolutely the same code) are treated differently by Google?

To resume, is enough to have the following in the manifest file to be sure that my app never request or use background location services?
B4X:
RemovePermission(android.permission.ACCESS_BACKGROUND_LOCATION)

I don't want to try by pushing the app to Play Store and to wait for a feedback from Google.
test
To resume, is enough to have the following in the manifest file to be sure that my app never request or use background location services?
B4X:
RemovePermission(android.permission.ACCESS_BACKGROUND_LOCATION)
 
Upvote 0
Top