traduccion google fusedlocationproviderclient fused example android location google-play-services android-geofence fusedlocationproviderapi

android - google - fusedlocationproviderclient example



Android play services 6.5: falta LocationClient (1)

Después de actualizar a Google Play Services 6.5.87, mi aplicación no pudo compilarse debido a la falta de la clase LocationCLient.

El enlace de documentación está dañado en este momento (404 no encontrado)

¿Cómo puedo arreglarlo? Quiero recibir actualizaciones de ubicación, trabajar con geofences, etc.


La clase LocationClient ha sido reemplazada por el nuevo FusedLocationProviderApi y el GeofencingApi , que utilizan la técnica de conexión común GoogleApiClient para conectarse a Google Play Services. Una vez que esté conectado, puede llamar a métodos como 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()); } } });