LocationManager manager = (LocationManager) getSystemService(LOCATION_SERVICE)
manager.requestLocationUpdates("rtt", 5000, 1, listener);
LocationListener listener = new LocationListener()
{
@Override
public void onLocationChanged(Location location) {location.getLongitude();location.getLatitude(); }
}
manager.removeUpdates(listener);
Location loc = manager.getLastKnownLocation("rtt")
1. manager.requestSingleUpdate("rtt", listener,Looper);//use this API for A10 and below
2. manager.getCurrentLocation("rtt",new CancellationSignal(), new CustomExecutor(),newConsumer<Location>()
{
@Override
public void accept (Location location) {
if (location != null) {
location.getLongitude();
location.getLatitude();
}
}
}); // use this AI for Android A11 and above