Created
August 15, 2018 19:59
-
-
Save FitzAfful/80e978016f7389ac2e1c792aeed718f7 to your computer and use it in GitHub Desktop.
Description of Error in using PlaceAutoComplete Builder in Android
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// call Google Places Autocomplete | |
try { | |
AutocompleteFilter autocompleteFilter = new AutocompleteFilter.Builder() | |
.setTypeFilter(Place.TYPE_COUNTRY) | |
.setCountry("GH") | |
.build(); | |
Intent intent = | |
new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY) | |
.setFilter(autocompleteFilter) | |
.build(AddressActivity.this); | |
startActivityForResult(intent, PLACE_AUTOCOMPLETE_REQUEST_CODE); | |
} catch (GooglePlayServicesRepairableException e) { | |
// TODO: Handle the error. | |
} catch (GooglePlayServicesNotAvailableException e) { | |
// TODO: Handle the error. | |
} | |
//onActivity Result | |
@Override | |
public void onActivityResult(int requestCode, int resultCode, Intent data) { | |
super.onActivityResult(requestCode, resultCode, data); | |
Log.e("Done "+ requestCode,"Requesting "+ resultCode); | |
if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) { | |
if (resultCode == RESULT_OK) { | |
Place place = PlaceAutocomplete.getPlace(this, data); | |
office.setText(place.getName()); | |
} else if (resultCode == PlaceAutocomplete.RESULT_ERROR) { | |
Status status = PlaceAutocomplete.getStatus(this, data); | |
Log.i("Address", status.getStatusMessage()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment