I can't determinate is GPS Turned ON or OFF, isProviderEnabled is always "false" but GPS is Turned ON.
public abstract class BaseGPSActivity extends AppCompatActivity{
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mLocationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
Log.v(TAG, " GPS is enabled: "+isGPSEnabled()))
public boolean isGPSEnabled(){
String provider = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
if(provider != null)
Log.v(TAG, " Location providers: "+provider);
return mLocationManager!=null && mLocationManager.isProviderEnabled( LocationManager.GPS_PROVIDER );
}
Output is :
V/BaseGPSActivity: Location providers: network
V/BaseGPSActivity: GPS is enabled: false
That was because need to check "High accuracy" in Settings of the device. That GPS Provider will be enabled.
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