Currently, I am building a functionality to search for a company with an AutocompleteTextView. To achieve this I use A PlaceAutocomplete IntentBuilder with the overlay mode like this:
try {
AutocompleteFilter typeFilter = new AutocompleteFilter.Builder()
.setTypeFilter(AutocompleteFilter.TYPE_FILTER_ESTABLISHMENT)
.setCountry("NL")
.build();
Intent intent = new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY)
.setFilter(typeFilter)
.build(activity);
activity.startActivityForResult(intent, placeAutocompleteRequestCode);
} catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException e) {
Log.e(TAG, "Something went wrong getting the places fragment." + e.getMessage());
}
I receive the place like this:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) {
if (resultCode == RESULT_OK) {
Place place = PlaceAutocomplete.getPlace(this, data);
Log.i(TAG, "Place: " + place.getName());
} else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
Status status = PlaceAutocomplete.getStatus(this, data);
Log.i(TAG, status.getStatusMessage());
} else if (resultCode == RESULT_CANCELED) {
// The user canceled the operation.
}
}
}
But I can't find the opening times in the 'place' object. How am I able to retrieve them? I can only find others who use the API, but I prefer this autocomplete fragment.
Also tried it with an API call to get the place details by place ID later but it appears that this is only allowed for server keys. If someone has this working with a release key on Android then it would be a nice hotfix for now. But still feels cumbersome.