user3659062
user3659062

Reputation: 3

how can I know if a latitude and longitude are close to my current location using google android api?

I just want to know how to use google android api to get my current location, display the location and compare that location with others latitudes and longitudes.

Upvotes: 0

Views: 61

Answers (1)

Doug Ray
Doug Ray

Reputation: 1010

Check out the android docs for everything you should need on location. So for example first you would get the current location like this

@Override
public void onConnected(Bundle connectionHint) {
    mLastLocation = LocationServices.FusedLocationApi.getLastLocation(
            mGoogleApiClient);
    if (mLastLocation != null) {
        mLatitudeText.setText(String.valueOf(mLastLocation.getLatitude()));
        mLongitudeText.setText(String.valueOf(mLastLocation.getLongitude()));
    }
}

then you would compare that with the other location using the method distanceBetween(Location dest)

Hope this helps.

Upvotes: 1

Related Questions