I am trying to get Latitude
and Longitude
using given below code but every time i am getting 0.00 and 0.00 lat
and long
as result.
locationManager = (LocationManager) getApplicationContext().getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 3000L, 1, listener);
Log.d("Network", "Network");
if (locationManager != null) {
location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
if (location != null) {
Log.e("Google latitude 111", location.getLatitude() + "");
Log.e("Google longitude 111", location.getLongitude() + "");
if (ServiceManager.lat.equals("") || ServiceManager.lng.equals("")) {
ServiceManager.lat = String.valueOf(location.getLatitude());
ServiceManager.lng = String.valueOf(location.getLongitude());
MainActivity.handler.sendEmptyMessage(Response.GOT_LOCATION);
}
}
}
I want to get actual latitude
and longitude
. I have taken and allowed all require permissions in device (FINE_LOCATION, COARSE_LOCATION and INTERNET
).My target SDK
version is 25. Is that any update in Androids Location Manager Policy for latest SDKs?