Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GPS Manifest: GPS in App is optional, want to make it available to GPS less devices too

On uploading my App onto the market today, I saw that it is only available to devices with GPS, so this excludes some tablets.

GPS in my App is optional. Is it possible to release one App for devices with and without GPS or do I need to make an extra version (would be no problem, though)?

If it is possible, I guess there is some sort of method to check if(deviceHasGPS()){...}. Is there one ?

This is the part of my manifest:

<uses-permission android:name="android.permission.PREVENT_POWER_KEY" /> <uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.WRITE_SETTINGS" /> <uses-permission android:name="com.android.vending.CHECK_LICENSE" /> 

Edit: thanks for the Answer Raghav Sood!

Add to Manifest:

<uses-feature android:name="android.hardware.location.gps"                android:required="false" /> 

Implement the following:

locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); boolean deviceHasGPS = false;     if (locationManager.getAllProviders().contains(LocationManager.GPS_PROVIDER)) {         deviceHasGPS = true;     } 

to test it on a device with gps, just surround the gps things with if(deviceHasGPS){...} then remove in the manifest:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 

set deviceHasGPS to always false and see if the App force closes.

like image 976
stefple Avatar asked Jun 17 '12 19:06

stefple


People also ask

What are manifest permissions?

The Android manifest file helps to declare the permissions that an app must have to access data from other apps. The Android manifest file also specifies the app's package name that helps the Android SDK while building the app.

What is Android permission Change_network_state?

CHANGE_NETWORK_STATE. change network connectivity. Allows the app to change the state of network connectivity.


1 Answers

Add the following to your manifest

<uses-feature android:name="android.hardware.location.gps" android:required="false" /> 

This will tell Google Play that while your app has the GPS, it's absolute requirement isn't true. However, you should handle the lack of GPS in your app gracefully, instead of letting it crash.

To check is the device has GPS you can call LocationManager.getAllProviders() and check whether LocationManager.GPS_PROVIDER is included in the list.

like image 104
Raghav Sood Avatar answered Oct 13 '22 00:10

Raghav Sood