3
我試圖使用Google Places API獲取某個地點的經度和緯度。GoogleApiClient未配置爲使用此通話所需的API
我下面這個例子:Google Directions Android
我配置客戶端這樣的:
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Places.GEO_DATA_API)
.addApi(Places.PLACE_DETECTION_API)
.addApi(LocationServices.API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
但後來這裏:
PendingResult<PlaceBuffer> placeResult = Places.GeoDataApi
.getPlaceById(mGoogleApiClient, placeId);
我得到以下錯誤:
java.lang.IllegalArgumentException: GoogleApiClient is not configured to use the API required for this call.
我該如何解決?
我在Google API控制檯上激活了API,我想我正在配置它,就像這個例子。
您是否在清單文件中添加了正確的配置? https://developers.google.com/places/android-api/start –
@MatiasElorriaga是的,我使用與Google地圖相同的API密鑰,並且地圖工作正常。 –
你叫'mGoogleApiClient.connect();' –