Saturday, July 21, 2012

How to check if GPS is currently enabled or disabled

Using the method Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED), we can get the allowed location provider, GPS. To check if GPS is currently enabled or disabled, using the code:

        String GpsProvider = Settings.Secure.getString(getContentResolver(),
         //GPS Disabled
         gpsState.setText("GPS Disable");
         //GPS Enabled
         gpsState.setText("GPS Enable");

No comments:

Post a Comment