It turned out to make the definition of coordinates:
public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { private LocationManager locationManagerGPS; locationManagerGPS.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5000, 0, locationListenerGPS); }; public static LocationListener locationListenerGPS = new LocationListener() { @Override public void onLocationChanged(Location locationGPS) { System.out.println(Double.toString(locationGPS.getLongitude())); System.out.println(Double.toString(locationGPS.getLatitude())); } @Override public void onStatusChanged(String s, int i, Bundle bundle) { } @Override public void onProviderEnabled(String s) { } @Override public void onProviderDisabled(String s) { } }; } But coordinates are determined only when the location changes. Is it possible to determine the current location by clicking a button?
Ie, for example, there was some kind of movement, coordinates were determined, arrived at the scene, you need to know the location of the stop, clicked on the "finish" button and the current coordinate is determined.