I'm using Google Maps API V1. I have this error :
java.lang.IllegalArgumentException: provider doesn't exisit: null
This is my code :
locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
String provider = locationManager.getBestProvider(criteria, true);
if (provider != null)
{
startTime = System.currentTimeMillis();
geoLocTimeOutTask = new GeoLocTimeOutTask();
geoLocTimeOutTask.execute();
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationListener);
}
else
{
geoLocCallbackObj.geoLocationCallback(tagCallback);
}
I understand the error, bu my question is, whay the device put me this error ? And how can I avoid this please ?
the suggested was to fix this would be to use the new location API instead of the old one http://developer.android.com/google/play-services/location.html
but really all you have to do it do a check
if the provider is not enabled then it wont pass and wont crash