Start Location setting if GPS disabled

The following code can be used to start Location setting:

Intent intent = new Intent(Settings.ACTION_SECURITY_SETTINGS);
startActivity(intent);


This example will start Location setting if GPS is curently disabled:
        String GpsProvider = Settings.Secure.getString(getContentResolver(),
Settings.Secure.LOCATION_PROVIDERS_ALLOWED);

if(GpsProvider.equals("")){
//GPS Disabled
gpsState.setText("GPS Disable");
Intent intent = new Intent(Settings.ACTION_SECURITY_SETTINGS);
startActivity(intent);
}else{
//GPS Enabled
gpsState.setText("GPS Enable");
}


Related:
- How to check if GPS is currently enabled or disabled
- Detect GPS ON/OFF status using android.provider.Settings.Secure
- Settings.ACTION_LOCATION_SOURCE_SETTINGS vs. Settings.ACTION_SECURITY_SETTINGS

0 Response to "Start Location setting if GPS disabled"

Posting Komentar