I'm trying to implement an application which senses position from both GPS and the network provider and shows it on a Google Map. I succeeded in doing this, but I have a question: I get the provider in the onCreate() of my Activity (it extends LocationListener)
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
provider = locationManager.getBestProvider(criteria, false);
location = locationManager.getLastKnownLocation(provider);
It works fine, my problem is that when onLocationChange() is called, I should act differently if the provider which called it is GPS or NETWORK. Is there a way to know which? To be more clear:
When onLocationChanged(Location location)
is called, is there a chance to know which provider made the call? I have tried using an if
on the provider string but it seems it doesn't work.