Places.PlaceDetectionApi.getCurrentPlace给出空结果和空的可能位置

时间:2017-06-19 01:46:54

标签: android google-places-api

private void getLocation()throws SecurityException {
    Log.e("TAG","Entered Get Location");
    PendingResult<PlaceLikelihoodBuffer>  result = Places.PlaceDetectionApi.getCurrentPlace(mGoogleApiClient, null);
            if(mGoogleApiClient!=null)
            {
                Log.e("TAG","Client Not Null "+mGoogleApiClient.toString());
            }
    result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
        @Override
        public void onResult(PlaceLikelihoodBuffer likelyPlaces) {
            Log.e("TAG","Result  " +likelyPlaces.getCount());
            for (PlaceLikelihood placeLikelihood : likelyPlaces) {
                Log.e("PLACES ",placeLikelihood.getPlace().getName().toString());
                tvLikelyPlaces.append(String.format("Place '%s' with " +
                                "likelihood: %g",
                        placeLikelihood.getPlace().getName(),
                        placeLikelihood.getLikelihood()) + "\n");
            }
            likelyPlaces.release();
        }
    });
}

我尝试记录可能的位置并且显示它是空的,我已经尝试在物理设备上进行测试。我没有得到任何其他错误,

我确信我的API设置可以与Google Client API成功连接,但Google Places API for Android似乎存在一些问题。 我已经提到了ACCESS_FINE_LOCATION,INTERNET和READ_GSERVICES权限

1 个答案:

答案 0 :(得分:0)

我通过在开发者控制台上启用Places api解决了这个问题 Google Map Api与Places api不同