我正在使用Google Places API
. 我在运行 PlaceDetectionApi 的 getCurrentPlace 方法时遇到问题。PlaceLikelihoodBuffer
我得到的resultcallback
方法是空的,当我errorstatus
在我的 logcat 中打印时,它说 errorcodenumber 是 13,在 logcat 中,我还可以读取“D/”行PlaceInferenceEngine: No place inference engine is running, returning null"
。我在我的 AVD 中运行它模拟器,不幸的是,我目前无法在真实设备上对其进行测试。所以,问题是:这个地方推理引擎是什么,我怎样才能让它在我的 AVD 上运行?
相关的代码是这样的:
public void getCurrentPosition(int requestCode) {
if(ContextCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) !=
PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION},
requestCode);
} else {
if(requestCode == PERMISSION_REQUEST_GET_CURRENT_POSITION) {
PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi.getCurrentPlace(client, new PlaceFilter());
result.setResultCallback(new ResultCallback<PlaceLikelihoodBuffer>() {
@Override
public void onResult(PlaceLikelihoodBuffer placeLikelihoods) {
System.out.println("inside callback...");
Status status = placeLikelihoods.getStatus();
System.out.println(status.isSuccess());
System.out.println(status.getStatusCode());
System.out.println(status.getStatusMessage());
for (PlaceLikelihood placeLikelihood : placeLikelihoods) {
Place place = placeLikelihood.getPlace();
System.out.println("possible place: " + place.getAddress());
}
placeLikelihoods.release();
}
});
}
}
}
我的 logcat 中的结果是:
06-19 14:39:33.436 1865-2848/com.google.android.gms.persistent D/PlaceInferenceEngine: No place inference engine is running, returning null
06-19 14:39:33.437 1865-2284/com.google.android.gms.persistent W/Places: getLastLocation returned null. Falling back to location updates
06-19 14:39:33.621 1865-2148/com.google.android.gms.persistent W/GCoreFlp: No location to return for getLastLocation()
06-19 14:39:43.478 1865-2284/com.google.android.gms.persistent E/Places: Timed out waiting for a location for getCurrentPlace
06-19 14:39:43.500 2760-2760/com.example.kevin.mapproject I/System.out: inside callback...
06-19 14:39:43.500 2760-2760/com.example.kevin.mapproject I/System.out: false
06-19 14:39:43.500 2760-2760/com.example.kevin.mapproject I/System.out: 13
06-19 14:39:43.500 2760-2760/com.example.kevin.mapproject I/System.out: ERROR