Android 使用google current Place api获取当前位置信息

Android 使用google current Place api获取当前位置信息,android,google-places-api,Android,Google Places Api,我想知道我所在位置的所有地方。我正在使用谷歌当前位置api private void getCurrentPlaceData() { mPlaceDetectionClient = Places.getPlaceDetectionClient(this); Task<PlaceLikelihoodBufferResponse> placeResult = mPlaceDetectionClient. getCurrentPlace(null)

我想知道我所在位置的所有地方。我正在使用谷歌当前位置api

private void getCurrentPlaceData() {
    mPlaceDetectionClient = Places.getPlaceDetectionClient(this);

    Task<PlaceLikelihoodBufferResponse> placeResult = mPlaceDetectionClient.
            getCurrentPlace(null);
    placeResult.addOnCompleteListener(new OnCompleteListener<PlaceLikelihoodBufferResponse>() {
        @Override
        public void onComplete(@NonNull Task<PlaceLikelihoodBufferResponse> task) {
            List<Place> placesList = new ArrayList<Place>();
            PlaceLikelihoodBufferResponse likelyPlaces = task.getResult();
            for (PlaceLikelihood placeLikelihood : likelyPlaces) {
                placesList.add(placeLikelihood.getPlace().freeze());
            }
            likelyPlaces.release();
            showAddPropertyNameDialog(AppStringConstants.ADD_NEW_STORE_TAG, placesList.get(0));
        }
    });
}

我访问了这个网站上的许多链接,没有人帮忙。

在清单文件的
标记中添加以下代码

 <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
 <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="PASTE_YOUR_API_KEY_HERE" />


是否已在清单文件中添加元数据?使用清单代码更新问题。是否已启用以下功能??Google地图距离矩阵API Google Places API Web服务Google Places API for Android和发布内容:提醒:要使用Places API,您必须获得API密钥,并且必须启用计费。您可以在获得API密钥时启用计费(请参阅快速指南),也可以作为单独的流程启用计费(请参阅使用和计费)。您必须启用计费权限
@RajneeshShukla您是在真正的设备或模拟器上测试它吗?我已经在移动设备和模拟器boththanks@Kartik上进行了测试,现在可以工作了。我所做的。。。如果未授予位置权限,我将显示警报对话框。它将打开权限屏幕,当用户允许时,它工作正常
com.google.android.gms.common.api.ApiException: 13: ERROR
 <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
 <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="PASTE_YOUR_API_KEY_HERE" />