Android Question FusedLocation and permissions

EduardoElias

Well-Known Member
Licensed User
Longtime User
From previous post:

"based on this, can i avoid to have the COARSE_LOCATION and FINE_LOCATION in manifest?

today I have
RemovePermission(android.permission.ACCESS_COARSE_LOCATION)
RemovePermission(android.permission.ACCESS_FINE_LOCATION)

on manifest, the reason is that my app will be incompatible with some tablet if I declare this permission.

However I need to use google maps, i was using it by browser and was somewhat working (some old tablets does not work properly)

I wanted to switch to the google maps views. I have the coordinates based on ZIPCODE what is all that I need from start and target and what to use this on the map, eventually even make the route.

Is this FusedLocation the way to go?"

From Erel reply

"FusedLocationProvider requires these permissions (at least COARSE_LOCATION).

The permission itself will never cause your app not to be compatible if you do it correctly. Start a new thread in the questions forum and I'll explain."
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I'm not sure that I understand. No permission is required if you only want to show a map.

on manifest, the reason is that my app will be incompatible with some tablet if I declare this permission.
When you upload your app to Google Play it extracts the used features based on the permissions. However you can explicitly add the required features and mark them as not required: https://www.b4x.com/android/forum/t...ony-android-required-false.40608/#post-243083

So you need to find out the problematic feature and add it as a not required feature.

See this table: https://developer.android.com/guide/topics/manifest/uses-feature-element.html#permissions-features
 
Upvote 0

EduardoElias

Well-Known Member
Licensed User
Longtime User
right now my manifest file looks like this:

B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="14"
        android:targetSdkVersion="14"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE"/>
<uses-permission android:name="android.permission.INTERNET" />
<supports-screens android:largeScreens="true"
    android:xlargeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
AddApplicationText(<activity android:name="anywheresoftware.b4a.objects.preferenceactivity"/>)
AddManifestText(<uses-feature android:name="android.hardware.telephony" android:required="false"/>)
AddManifestText(<uses-feature android:name="android.hardware.bluetooth" android:required="false" />)
AddManifestText(<uses-feature android:name="android.hardware.usb.accessory" android:required="false" />)
AddManifestText(<uses-feature android:name="android.hardware.usb.host" android:required="false" />)
AddManifestText(<uses-feature android:name="android.hardware.camera" android:required="false" />)
AddManifestText(<uses-feature android:name="android.hardware.FAKETOUCH" android:required="false" />)
AddManifestText(<uses-feature android:name="android.hardware.LOCATION" android:required="false" />)
AddManifestText(<uses-feature android:name="android.hardware.location.GPS" android:required="false" />)
AddManifestText(<uses-feature android:name="android.hardware.location.NETWORK" android:required="false" />)
AddManifestText(<uses-feature android:name="android.hardware.WIFI" android:required="false"/>)
AddManifestText(<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>)
AddManifestText(<uses-feature android:name="android.hardware.touchscreen" android:required="false" />)
AddManifestText(<uses-feature android:name="android.permission.WAKE_LOCK" android:required="false" />)
AddManifestText(<uses-feature android:name="android.permission.ACCESS_FINE_LOCATION" android:required="false" />)
AddManifestText(<uses-feature android:name="android.permission.ACCESS_COARSE_LOCATION" android:required="false" />)
RemovePermission(android.permission.ACCESS_COARSE_LOCATION)
RemovePermission(android.permission.ACCESS_FINE_LOCATION)
RemovePermission(android.permission.VIBRATE)
RemovePermission(android.permission.BLUETOOTH_PRIVILEGED)
RemovePermission(android.permission.BLUETOOTH_ADMIN)
RemovePermission(android.permission.WAKE_LOCK)
AddApplicationText(<meta-data
 android:name="com.google.android.geo.API_KEY"
 android:value="XXXXXXXXXXXXXXXXXXXXXXXXXXXX"/>
 <meta-data android:name="com.google.android.gms.version"
   android:value="@integer/google_play_services_version" />
   )
AddActivityText(main, <intent-filter >
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.HOME" />
        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>)   
'AddActivityText(main, <intent-filter>
'        <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
'    </intent-filter>
'    <meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
'        android:resource="@xml/device_filter" />)
'End of default text.

Maybe I am wrong. I was having trouble with some chinese tablets that is found on our market, and I got to the point to every version I removed a permission and uploaded to the store until my app appeared on the desired tablets.

This problem is that even in the tablet library theses tablets are displayed as generic equipment, so no help here.

What is the difference:

AddManifestText(<uses-feature android:name="android.permission.ACCESS_FINE_LOCATION" android:required="false" />)
AddManifestText(<uses-feature android:name="android.permission.ACCESS_COARSE_LOCATION" android:required="false" />)

and this

RemovePermission(android.permission.ACCESS_COARSE_LOCATION)
RemovePermission(android.permission.ACCESS_FINE_LOCATION)
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Note that can use a single AddManifestText command to add all the text.

What is the difference:

AddManifestText(<uses-feature android:name="android.permission.ACCESS_FINE_LOCATION" android:required="false" />)
AddManifestText(<uses-feature android:name="android.permission.ACCESS_COARSE_LOCATION" android:required="false" />)

and this

RemovePermission(android.permission.ACCESS_COARSE_LOCATION)
RemovePermission(android.permission.ACCESS_FINE_LOCATION)
By adding the uses feature elements you can keep the permissions and your app will not be filtered. It all depends on whether you actually need the permission or not. If not then removing it is the best option.
 
Upvote 0
Top