Steps
1. specify using Google Services
2. Access fine location
To have connection callbacks
– implements ConnectionCallbacks, OnConnectionFailedListener
@Override
public void onConnected(Bundle bundle){
super.onStart();
mGoogleApiClient.connect();
}
@Override
protected void onStop(){
super.onStop();
if(mGoogleApiClient.isConnected()) {
mGoogleApiClient.disconnected();
}
}
@Override
protected void onConnected(Bundle connectionHint){
mLastLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
if(mLastLocation!=null){
mLatitudeText.setText(String.valueOf(mLastLocation.getLatitude()));
mLongitudeText.setText(String.valueOf(mLastLocation.getLongitude()));
}
}
Setting up
-create App
-edit the Layout
-Add String.xml
-Update Build.gradle and AnxdroidManifest.xml