I am trying to implement places autocomplete widget in my app, but when I open the widget it instantly closes and outputs in the logcat:
E/Places: Autocomplete widget closing due to PLACES_API_ACCESS_NOT_CONFIGURED
It correctly identifies the key in the AndroidManifest.xml
. The API key is unrestricted, so that can't be the problem.
My code:
place.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
Intent intent =
new PlaceAutocomplete.IntentBuilder(PlaceAutocomplete.MODE_OVERLAY)
.build(getActivity());
startActivityForResult(intent, 1);
} catch (GooglePlayServicesRepairableException e) {
Toast.makeText(getActivity(), "GooglePlayServicesRepairableException",
Toast.LENGTH_LONG).show();
} catch (GooglePlayServicesNotAvailableException e) {
Toast.makeText(getActivity(), "GooglePlayServicesNotAvailableException",
Toast.LENGTH_LONG).show();
}
}
});