Android. Defining coordinates

How do I determine the coordinates on the request?

For example, now I know the coordinates like this:

locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000 * 10, 10, locationListener);
        locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000 * 10, 10, locationListener);

 private LocationListener locationListener = new LocationListener() {

    @Override
    public void onLocationChanged(Location location) {}

    @Override
    public void onProviderDisabled(String provider) {}

    @Override
    public void onProviderEnabled(String provider) {}

    @Override
    public void onStatusChanged(String provider, int status, Bundle extras){}
};

But there is one catch, it will call a subscription to the event-LocationListener, depending on the change in my coordinates or in time.

I don't need that. I want to get the coordinates once and continue working with them, and get them again if necessary.

If you pass in the parameters time = 0 and meters = 0, then it will simply be the maximum update coordinates frequently.

Author: inkognitum, 2015-11-29

1 answers

Starting with API 9, there is a fine requestSingleUpdate(...) method at LocationManager for such purposes.
Or pay attention to getLastKnownLocation(...).

 3
Author: Eugene Krivenja, 2015-11-30 10:00:41