Службы Android для Android 6.5: LocationClient отсутствует - программирование
Подтвердить что ты не робот

Службы Android для Android 6.5: LocationClient отсутствует

После обновления до Google Play Services 6.5.87 мое приложение не удалось скомпилировать из-за отсутствия класса LocationCLient.

Ссылка документация повреждена на данный момент (404 не найдено)

Как я могу это исправить? Я хочу получать обновления местоположения, работать с геозонами и т.д.

4b9b3361

Ответ 1

Класс LocationClient был заменен новым FusedLocationProviderApi и GeofencingApi, оба из которых используют общий метод соединения 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());
        }
   }
});