Android播放服务6.5:LocationClient丢失
在更新到Google Play Services 6.5.87之后,我的应用程序由于缺lessLocationCLient类而无法编译。
文档链接此刻被损坏(404 Not Found)
我该如何解决? 我想要接收位置更新,使用地理栅栏等。
LocationClient类已被replace为新的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()); } } });