Android Google place picker widget does not work

According to this official post

I am following the steps below to integrate the place picker UI dialog box with map

Initiator code

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

内部onActivityResult()

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

我已添加所有权限&清单文件中的API_KEY

问题是我无法从“位置选择器”对话框中选择位置.

Select button is disabled

认情况下,“选择”按钮是禁用的.

解决方法:

我已经解决了这个问题,所以我不太清楚这些步骤中的哪一个可以解决

在console.developer.google.com中

我启用了Places API和Maps API,并从here下载json.

另外,从“凭据”页面获取API密钥.

在Android Studio

在清单中,在< application>之间添加…< / application>

<Meta-data android:name="com.google.android.geo.API_KEY" android:value="YOUR_KEY_FROM_CREDENTIAL_PAGE"/>
@H_502_11@

在onCreate()中添加内容(尽管我不太确定是否需要这样做)

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

其他所有内容均遵循here中的教程.此外,我在发行版中对其进行了测试.如果仍然存在相同的问题,请尝试发布一个.我无法在模拟器中找到位置,但是在手机中可以正常工作.

希望这可以对将来的任何人有所帮助.

总结

以上是编程之家为你收集整理的android-Google Place Picker小部件不起作用全部内容,希望文章能够帮你解决android-Google Place Picker小部件不起作用所遇到的程序开发问题。

如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
喜欢与人分享编程技术与工作经验,欢迎加入编程之家官方交流群!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>