I have been struggling with Google Places API, I need to use the Address API.
I used the autoComplete and the placePicker APIs just fine,
To add the Address API you need to add an option like this:
Address.AddressOptions options = new Address.AddressOptions(AddressConstants.Themes.THEME_LIGHT);
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Address.API, options)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
Then you can request the address:
UserAddressRequest request = UserAddressRequest.newBuilder().build();
Address.requestUserAddress(mGoogleApiClient, request,
REQUEST_CODE);
And then you get the result:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case REQUEST_CODE:
switch (resultCode) {
case Activity.RESULT_OK:
UserAddress userAddress = UserAddress.fromIntent(data);
//DO SOMETHING
break;
case Activity.RESULT_CANCELED:
break;
default:
//NO ADDRESS
break;
}
break;
}
}
And add this to your gradle:
compile 'com.google.android.gms:play-services-identity:8.1.0'