Android的播放服务6

Android的播放服务6

本文介绍了Android的播放服务6.5:LocationClient是失踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新到谷歌播放服务87年6月5日以后我的应用程序中失败,因为缺少LocationCLient类的编译​​。

After updating to Google Play Services 6.5.87 my app was failed to compile because of missing LocationCLient class.

的documentation链接被破坏的那一刻(404未找​​到)

The documentation link is corrupted at the moment (404 Not Found)

我该如何解决呢?我希望收到位置更新,与geofences工作,等等。

How can I fix it?I want to receive location updates, work with geofences, etc..

推荐答案

在LocationClient类已被替换为新的FusedLocationProviderApi而GeofencingApi,它们都使用普通的 GoogleApiClient 连接技术连接到谷歌播放服务。一旦连接,你可以调用的方法,如requestLocationUpdates():

The LocationClient class has been replaced with the new FusedLocationProviderApi and the GeofencingApi, both of which use the common GoogleApiClient connection technique to connect to Google Play Services. Once you are connected, you can call methods such as 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());
        }
   }
});

这篇关于Android的播放服务6.5:LocationClient是失踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 04:04