gpt4 book ai didi

安卓播放服务6.5 : LocationClient is missing

转载 作者:IT王子 更新时间:2023-10-28 23:50:31 26 4
gpt4 key购买 nike

更新到 Google Play 服务 6.5.87 后,我的应用由于缺少 LocationCLient 类而无法编译。

documentation link目前已损坏(404 Not Found)

我该如何解决?我想接收位置更新、使用地理围栏等。

最佳答案

LocationClient 类已替换为新的 FusedLocationProviderApiGeofencingApi , 两者都使用共同的 GoogleApiClient连接到 Google Play 服务的连接技术。连接后,可以调用requestLocationUpdates()等方法:

LocationRequest locationRequest = LocationRequest.create()
.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);

PendingResult<Status> result = LocationServices.FusedLocationApi
.requestLocationUpdates(
googleApiClient, // your connected GoogleApiClient
locationRequest, // a request to receive a new location
locationListener); // the listener which will receive updated locations

// Callback is asynchronous. Use await() on a background thread or listen for
// the ResultCallback
result.setResultCallback(new ResultCallback<Status>() {
void onResult(Status status) {
if (status.isSuccess()) {
// Successfully registered
} else if (status.hasResolution()) {
// Google provides a way to fix the issue
status.startResolutionForResult(
activity, // your current activity used to receive the result
RESULT_CODE); // the result code you'll look for in your
// onActivityResult method to retry registering
} else {
// No recovery. Weep softly or inform the user.
Log.e(TAG, "Registering failed: " + status.getStatusMessage());
}
}
});

关于安卓播放服务6.5 : LocationClient is missing,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27372638/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com