Vote count:
0
Hello I am using following code to get location usin GPS I have given all required permission in AndroidManifest.xml
if (DeviceUtilities.isNetworkAvailable(context))
{
Toast.makeText(HomeScreen.this, "Getting location from GPS",Toast.LENGTH_SHORT).show();
LocationManager lm;
lm = (LocationManager) getSystemService(LOCATION_SERVICE);
Criteria c = new Criteria();
c.setAccuracy(Criteria.ACCURACY_FINE);
String bestProvider = lm.getBestProvider(c, true);
Location location = lm.getLastKnownLocation(bestProvider);
if(location!=null)
{
latitude = location.getLatitude();
longitude = location.getLongitude();
}
}
But getting null values for latitude and longitude. How do I can get location? Please suggest. Thanks in advance.
asked 1 min ago
How to get location using GPS?
Aucun commentaire:
Enregistrer un commentaire