Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why check of GPS_PROVIDER isProviderEnabled is always "false"? [duplicate]

Tags:

android

gps

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
like image 362
NickUnuchek Avatar asked Jan 06 '23 17:01

NickUnuchek


1 Answers

That was because need to check "High accuracy" in Settings of the device. That GPS Provider will be enabled. enter image description here

like image 106
NickUnuchek Avatar answered Feb 18 '23 07:02

NickUnuchek