Android Question Background location access not declared

D

Deleted member 103

Guest
Hi,

my app was not approved by google because of this policy (see thread title) .
Issue with your app​
We found the following issue(s) with your app:

Eligibility Issue
Background location access not declared
We detected that your app contains at least one feature that requests background location access, however you have not submitted a permission declaration form for this feature. Please log in to your Play Console and submit a declaration form.

Affected APK(s):
APK:64
Reasons of violation
About the Permissions & Location Permissions policies​
You may only request permissions that are necessary to implement critical current features or services in your application. You may not use permissions that give access to user or device data for undisclosed, unimplemented, or disallowed features or purposes. In order for our team to check for compliance, we must be able to review and verify your in-app experience.
Publishing Status
App status: Rejected​
Your app has been rejected and wasn't published due to this policy issue. If you submitted an update, the previous version of your app is still available on Google Play.

But I am not aware that where I need background location access.
This is the app manifest:
B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="29"/>
<uses-feature android:name="android.hardware.location.gps"/>
<supports-screens android:xlargeScreens="true"
    android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="false"
    android:anyDensity="true" />)
    'android:requiresSmallestWidthDp="500"
'SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
SetApplicationAttribute(android:largeHeap, "true")
'Neu ab SDK-29
SetApplicationAttribute(android:requestLegacyExternalStorage, true)
'End of default text.


'Einstellung für Adaptive-icon
SetApplicationAttribute(android:icon, "@mipmap/ic_launcher")
CreateResource(mipmap-anydpi-v26, ic_launcher.xml,
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
    <background android:drawable="@mipmap/background"/>
    <foreground android:drawable="@mipmap/foreground"/>
</adaptive-icon>
)

AddPermission(android.permission.ACCESS_FINE_LOCATION)
AddPermission(android.permission.WRITE_SETTINGS)
AddPermission(android.permission.WRITE_EXTERNAL_STORAGE)
AddPermission(android.permission.READ_PHONE_STATE)

'************ AppCompat components ************
SetApplicationAttribute(android:theme, "@style/MyAppTheme")
CreateResource(values, theme.xml,
<resources>
    <style name="MyAppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="colorPrimary">#607D8B</item>
        <item name="colorPrimaryDark">#455A64</item>
        <item name="colorAccent">#607D8B</item>
        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
    </style>
</resources>
)

'************ Required for Maps ************
AddApplicationText(
<meta-data
  android:name="com.google.android.geo.API_KEY"
  android:value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"/>
)
AddApplicationText(
<uses-library
      android:name="org.apache.http.legacy"
      android:required="false" />
)
'End of Required for Maps

'************ Crashlytics components ************
'Google Play Services Base - Always required when using Google Play Services or Firebase:
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)

'Firebase Analytics
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)

'Crashlytics components
CreateResourceFromFile(Macro, FirebaseAnalytics.Crashlytics)
'End of Crashlytics components

'GooglePlayBilling - In App Purchases
CreateResourceFromFile(Macro, GooglePlayBilling.GooglePlayBilling)
'End of GooglePlayBilling

'************ File Provider ****************
'E-Mail senden ab Android 6+
AddApplicationText(
  <provider
  android:name="android.support.v4.content.FileProvider"
  android:authorities="$PACKAGE$.provider"
  android:exported="false"
  android:grantUriPermissions="true">
  <meta-data
  android:name="android.support.FILE_PROVIDER_PATHS"
  android:resource="@xml/provider_paths"/>
  </provider>
)
CreateResource(xml, provider_paths,
   <external-files-path name="name" path="" />
)
'Ende of File Provider

and these are the permission:
<permission android:name="fg.MasterOfRegolarity.permission.C2D_MESSAGE"
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="com.android.vending.BILLING"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="fg.MasterOfRegolarity.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<uses-permission android:name="fg.MasterOfRegolarity.permission.C2D_MESSAGE"/>
<uses-permission android:name="com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE"/>

and this is my code with which I ask the permission:
B4X:
Private Sub CheckAndRequestPermission
    If Not(Starter.rp.Check( Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)) Then
        Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
    End If

    If Not(Starter.rp.Check( Starter.rp.PERMISSION_WRITE_EXTERNAL_STORAGE)) Then
        Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
    End If
End Sub

Sub Activity_PermissionResult (Permission As String, Result As Boolean)
    If Result = False Then
        Select Permission
            Case Starter.rp.PERMISSION_ACCESS_FINE_LOCATION
                Msgbox2Async(Starter.Language.Value("ACCESS_FINE_LOCATION"), Starter.Language.Value("PermissionDenied"), "OK","","",Null, False)

            Case Starter.rp.PERMISSION_WRITE_EXTERNAL_STORAGE
                Msgbox2Async(Starter.Language.Value("WRITE_EXTERNAL_STORAGE"), Starter.Language.Value("PermissionDenied"), "OK","","",Null, False)
        End Select
    End If
End Sub

In Main->Activity_Resume is this code :
B4X:
Sub Activity_Resume
...
    If Starter.rp.Check( Starter.rp.PERMISSION_ACCESS_FINE_LOCATION) Then
        If Not(Starter.GPS1.GPSEnabled) Then
            ToastMessageShow(Starter.language.value("msgEnableGpsDevice"), True)
            StartActivity(Starter.GPS1.LocationSettingsIntent) 'Will open the relevant settings screen.
        Else
            CallSub(Starter, "StartGPSAndTimer")
        End If
    End If
...
End Sub

and in Starter-Service:
B4X:
Sub Service_Create
...
    GPS1.Initialize("GPS1")
    GPSPathPreviuous.Initialize
...
End Sub

Public Sub StartGPSAndTimer
    If Not(GPS_On) Then
        GPS1.Start(GPSMinTime, GPSMinDistance) 'Listen to GPS with no filters.
        GPS_On = True
    End If
End Sub

I don't know what to change now.
 

drgottjr

Well-Known Member
Licensed User
Longtime User
you cannot leave tracking on all the time. google wants you to
B4X:
 ... log in to your Play Console and submit a declaration form.
which, they will probably reject anyway unless you have an important reason for tracking.
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
My only guess why google is thinking this, is that since services can run in the background without the app's activity showing, and since your gps routine is in a service, that would allow your app to track in the background - and background tracking is not allowed without special permission from google.

If your app does not need to track the user when your app is in the background (your apps' activity is not showing), then maybe moving the GPS object to an activity might fix this rejection. Otherwise if your app needs to track a users location when your app is not in the foreground, then you need to explain why to google by submitting a permission declaration form.

My guess is based on this page:


Specifically these parts:

Look for use of location access APIs, such as the Fused Location Provider API, Geofencing API, or LocationManager API, within your code such as in the following constructs:
(because the above code areas would allow you to track the user in the background)

and

If possible, refactor your location access logic so that you request location only when your app's activity is visible to users.
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
There is a new requirement in Android 10+ devices.
In order for the location tracking to continue working in the background, if the user chooses the "allow while app is open" permission option we need to add this line to the manifest editor:
B4X:
SetServiceAttribute(Tracker, android:foregroundServiceType, "location")
 
Upvote 0
D

Deleted member 103

Guest
SetServiceAttribute(Tracker, android:foregroundServiceType, "location")
Hi Manfred,
then I should move the whole GPS code to an extra service and enter this line in the manifest, right?
I'll just try it and see what Google says.
 
Upvote 0
D

Deleted member 103

Guest
I'm not sure that it is a technical issue.

Do you actually need to monitor the location while the app is in the background?

My app is an app for classic car drivers, which means that the app should also record and evaluate the GPS data in the background.
The app always runs normally in the foreground, but if the user receives a phone call, the app should continue to run in the background for this time.
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
I don't know if this will help or not with your declaration form, but it seems that if you include this line in the manifest:

B4X:
AddPermission(android.permission.ACCESS_BACKGROUND_LOCATION)

I think this line will cause the prompt that gets displayed to the user to change from "Allow app to access your location? Allow/Deny" to additionally say "Allow app to access your location? Deny/Only when running app/Always" - in other words it expands the question to allow the user to explicitly approve background tracking.

Maybe this can help you with your declaration form because if the user specifically allows background tracking, then hopefully google won't have as much of a problem with your app doing background tracking if the user specifically approves it.
 
Last edited:
Upvote 0
D

Deleted member 103

Guest
I don't know if this will help or not with your declaration form, but it seems that if you include this line in the manifest:
No, this line is not in the manifest, see my first post.
The problem is I have to solve the problem as soon as possible, because otherwise I will have the same problem with my other apps that also use GPS.

Here is a video of the demostration: Video
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
No, this line is not in the manifest, see my first post.
The problem is I have to solve the problem as soon as possible, because otherwise I will have the same problem with my other apps that also use GPS.

Since you would like to do background tracking, you will need to submit the declaration form to ask google for their approval to do background tracking.

So, what I was suggesting is to add that permission to your manifest so that your app will require the user to specifically approve "background" tracking.

And then maybe if you mention (in the declaration form) that your app specifically asks the user for approval of background tracking, this might help convince google to approve your declaration form.

It's just an idea to hopefully increase the chances of getting google to approve your declaration form.
 
Last edited:
Upvote 0
D

Deleted member 103

Guest
Since you would like to do background tracking, you will need to submit the declaration form to ask google for their approval to do background tracking.

So, what I was suggesting is to add that permission to your manifest so that your app will require the user to specifically approve "background" tracking.

And then maybe if you mention (in the declaration form) that your app specifically asks the user for approval of background tracking, this might help convince google to approve your declaration form.

It's just an idea to hopefully increase the chances of getting google to approve your declaration form.

here is a new video : Video
I hope I can convince google better with it.
 
Upvote 0
D

Deleted member 103

Guest
In that case you do need to declaration form. There is a link in the page I linked above.
I also filled out the declaration form.
1604572534753.png


After my last update and new video, google still doesn't want to approve my update.
I don't know what to do anymore. :rolleyes:
 
Last edited by a moderator:
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Why don't you try my idea of adding the manifest entry so that the permission prompt will then additionally display "Allow Location in background/always" (I forget the exact phrase).

And then make sure the video CLEARY shows that the user is presented with this option of "Background location".

And then put in the declaration form "My app specifically asks the user if they will allow background location tracking, so it is clearly explained to the user, and background tracking will ONLY happen if the user specifically approves it".
 
Last edited:
Upvote 0
D

Deleted member 103

Guest
AddPermission(android.permission.ACCESS_BACKGROUND_LOCATION)
I can enter this permission in the manifest, but it doesn't exist in B4x.
1604576349328.png


And then put in the declaration form "My app specifically asks the user if they will allow background location tracking, so it is clearly explained to the user and background tracking will ONLY happen is the user specifically approves it".
I have entered your text in the declaration form. Now I have to wait again what google says.

I have last video update.
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
I can enter this permission in the manifest, but it doesn't exist in B4x.
That new line in the manifest should cause the permission prompt that is displayed to the user to additionally include a phrase similar to "Allow Always/Background".

Can you try adding that line to your manifest and confirm that the "PERMISSION_ACCESS_FINE_LOCATION" prompt now has a "Allow always/background" (or similar phrase)?

You should submit a new video to google to show them that the user is specifically given the choice to allow background tracking.
 
Upvote 0
D

Deleted member 103

Guest
This is what is displayed at startup, even if I enter this line: AddPermission(android.permission.ACCESS_BACKGROUND_LOCATION)
1604604629803.png


But I am no longer so sure that my app needs this ACCESS_BACKGROUND_LOCATION, because when the app is closed, the location access ends.
Here is a new video
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
On this page:


It says "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."

But don't remove the ACCESS_BACKGROUND_LOCATION from the manifest.

What's important to notice from that page is that if you HAVE the "ACCESS_BACKGROUND_LOCATION" in the manifest, then the access prompt to the customer should now include an "always" option (in addition to "deny" and "allow only while using app".

But it seems this additional option (of "always") will only appear if the app is running on an Android 10 device.

So, what I would recommend is to:

1) Explain to the user why background tracking is needed for your app using my method:


2) Then install your app on an adroid 10 device and include the ACCESS_BACKGROUND_LOCATION permission in the manifest.

3) Record a new video that shows how your app explains to the user why background location is needed (possibly using my method as explained above), then when your app prompts the user for the "ACCESS_FINE_LOCATION" permission, the prompt should now automatically include an "Always" option. Make sure the new video shows this "always" option.

4) Then resubmit a new disclosure form with the new video and the text of "My app explains in detail to the user why background tracking is needed. Then my app specifically asks the user if they will allow background location tracking. So background tracking will ONLY happen if the user specifically approves it"
 
Upvote 0
D

Deleted member 103

Guest
Hi,
now it worked! :)
I explained in the declaration form that the app does not use any location access in the background.
It is also not necessary, because location access is only used when the app is running.
I probably just got confused with the declaration form.

@JohnC , Thank you for your help.

Google Play Console Logo
Hello,
Your update to Master-Of-Regularity, created on Nov 6, 2020 at 10:39 AM GMT, is live in the store.
QYDyyhHJ2fk28WGEPkRqyvFyPJrOyw7iB4Ut4CCUfue0VKjOQ9WOkmOKQ6zMXAOqHw
Master-Of-Regularity
fg.MasterOfRegolarity
Sincerely,
The Google Play team
If you don’t want to receive notifications when app updates go live, update your email notification settings.
 
Upvote 0
D

Deleted member 103

Guest
New version -> same problem!
I uploaded a version on 11/9/2020 and it was approved by Google.
Now I've uploaded a new version and it's not approved, why?
Apart from a new IF query, nothing has been added or changed in the app.

The only difference between this app and another one that doesn't cause any problems is the area marked in red.

1608289121001.png
 
Upvote 0
Top