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.
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.
CHANGE_NETWORK_STATE. change network connectivity. Allows the app to change the state of network connectivity.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With