Code example for FragmentActivity

Methods: getSystemService, onStart

    protected void onStart() { 
        // Check if the GPS setting is currently enabled on the device. 
        // This verification should be done during onStart() because the system calls this method 
        // when the user returns to the activity, which ensures the desired location provider is 
        // enabled each time the activity resumes from the stopped state. 
        LocationManager mLocationManager =
                (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        final boolean gpsEnabled = mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
        if (!gpsEnabled) {