Vol*_*man 45 android location google-play-services android-geofence fusedlocationproviderapi
更新到Google Play Services 6.5.87后,由于缺少LocationCLient类,我的应用程序无法编译.
的文档链接 是在瞬间损坏(404未找到)
我该如何解决?我想收到位置更新,使用地理围栏等.
ian*_*ake 56
LocationClient类已被新的FusedLocationProviderApi和GeofencingApi取代,两者都使用常见的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());
}
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10884 次 |
| 最近记录: |