Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Location: GPS/network permissions: wanted if available

I want my application to access GPS/Network locations if they are availabe. I don't want Google Play to filter out devices without GPS/Network locator.

How should I do this?

Currently I have this on my manifest:

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature android:name="android.hardware.telephony" android:required="false" />
<uses-feature android:name="android.hardware.location" android:required="false" />

However, I am not sure it that is enough, because http://developer.android.com/guide/topics/manifest/uses-feature-element.html#permissions-features states that:

-permission ACCESS_COARSE_LOCATION implies android.hardware.location.network and android.hardware.location features requirement

-permission *ACCESS_FINE_LOCATION implies android.hardware.location.gps and android.hardware.location

Do I also have to add <uses-feature android:name="android.hardware.location.network" android:required="false" /> and <uses-feature android:name="android.hardware.location.gps" android:required="false" /> ?

Why?

Shouldn't <uses-feature android:name="android.hardware.location" android:required="false" /> be enough?

like image 656
pandre Avatar asked Jul 12 '12 17:07

pandre


1 Answers

Yes, you must include them all because of the way that the permissions are stored in the API. They are stored as Strings in the PackageManager class. Take for example the one you're concerned about, android.hardware.location. See how it the string is exactly the same as what you type in the Manifest. Google Play looks for these exact matches when filtering. So android.hardware.location.gps is not actually a child of android.hardware.location, it is just represented like that for the sake of organization.

like image 198
gobernador Avatar answered Nov 03 '22 12:11

gobernador