When you start the application, you need to get the user's location on the map. Googling and looking in the book, the only thing I found was to use the distance change listener:
LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, new LocationListener() { @Override public void onLocationChanged(Location location) { //Получаю местоположение и отписываюсь locationManager.removeUpdates(this); ... } ... } This method does not always work. Sometimes the application waits 10 seconds or 2 minutes before the listener works. Sometimes it just does not work (if the phone does not move).
Is there any 100% working alternative to request the current distance (under conditions of normal GPS operation), and not wait for a response to the listener changes?