Reputation: 3
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
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