Locationmanager's Location In Android Returns Null
I'm testing my Android app on a device, and it always fails when I use locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener); currentLocation
Solution 1:
GPS_PROVIDER may not work in bounded place, suppose inside a house or something like this. You should program it in such a way that if gps provider gives null location then you use network provider as a alternative although its accuracy is not so high. Here there is another issue. Your code should be as follows:
if(locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)
{
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
currentLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
}
Post a Comment for "Locationmanager's Location In Android Returns Null"