Android GPS on or off state

zsniperx picture zsniperx · Nov 29, 2010 · Viewed 24.9k times · Source

Is there any way to check if the Android GPS is on or off without any permission, just the state I don't need to toggle it.

Thanks

Answer

Raunak picture Raunak · Nov 29, 2010

No. Checking GPS Status on Android requires

android.permission.ACCESS_FINE_LOCATION

The code to check the status of GPS


 LocationManager manager = (LocationManager) getSystemService(Context.LOCATION_SERVICE );
 boolean statusOfGPS = manager.isProviderEnabled(LocationManager.GPS_PROVIDER);