I've written an android application that needs the user location, it was working fine when I used gps provider, but I don't want to use GPS because it uses a lot of battery, here is my code
LocationManager locaionManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,5*1000,0, new MyLocaionListener());
Location loco = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
Log.d("enabled=" ,"" + locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER));
This code returns a null
Location Object, and the logCat shows enabled=false
when the location service is disabled although I'm using NETWORK_PROVIDER But when I enable the location service from the phone settings I get enabled=true
and I get my current location.
So my question is:
does network provider also uses the phone GPS? and how do GPS and NETWORK providers internally works.