2016-08-25 63 views
2

根據This Official Post谷歌將選擇器窗口小部件不工作

我按照以下步驟將選擇器UI對話框,地圖整合。

啓動代碼

PlacePicker.IntentBuilder builder = new PlacePicker.IntentBuilder(); 
    startActivityForResult(builder.build(this), PLACE_PICKER_REQUEST); 

if (requestCode == PLACE_PICKER_REQUEST) { 
     if (resultCode == RESULT_OK) { 
      Place place = PlacePicker.getPlace(this, data); 
      tvChooseLocation.setText(place.getName()); 
     } 
    } 

我已經添加的所有權限清單文件

問題是我無法從選擇位置& API_KEY onActivityResult()放置選取器對話框。

Select button is disabled

選擇按鈕默認情況下禁用。

+0

可能的重複https://stackoverflow.com/questions/39092825/disable-select-button-while-selecting-location-of-anonymous-location-using-place – AndrewR

+0

@AndrewR謝謝,但答案仍未找到。 – Aks4125

+0

你解決了這個問題嗎?我得到相同的行爲 – GEPD

回答

1

嘗試啓用谷歌Places API的從谷歌開發者控制檯

Link to console

--Wanted雖然發表評論,但沒有權限。

+0

仍然是相同的問題 –

+0

@VikasPandey請嘗試我已發佈的答案,如果您仍然有問題 – August

1

我已經解決了這個讓我不太知道其中一個步驟解決它

在console.developer.google.com

我讓鄰居API和Maps API和下載來自here的json。

另外,從Credential頁面獲取API密鑰。

在Android Studio中

在清單中,<application> ... </application>

之間

<meta-data android:name="com.google.android.geo.API_KEY" android:value="YOUR_KEY_FROM_CREDENTIAL_PAGE"/> 
加在的onCreate(),添加這個(雖然我不能肯定這是需要與否)

private GoogleApiClient mGoogleApiClient; 
mGoogleApiClient = new GoogleApiClient 
.Builder(this) 
.addApi(Places.GEO_DATA_API) 
.addApi(Places.PLACE_DETECTION_API) 
.enableAutoManage(this, this) 
.build(); 

其他一切只是按照教程here。另外,我在發行版中測試了它。如果您仍然遇到同樣的問題,請嘗試製作發行版。我沒有在模擬器中找到位置,但它在我的手機中工作得很好。

希望這可以幫助任何人在未來。