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权限
答案 0 :(得分:0)
我通过在开发者控制台上启用Places api解决了这个问题 Google Map Api与Places api不同