Request location updates on Android Wear

@Override public void onConnected(Bundle bundle) { LocationRequest locationRequest = LocationRequest.create() .setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY) .setInterval(UPDATE_INTERVAL_MS) .setFastestInterval(FASTEST_INTERVAL_MS); LocationServices.FusedLocationApi .requestLocationUpdates(mGoogleApiClient, locationRequest, this) .setResultCallback(new ResultCallback() { @Override public void onResult(Status status) { if (status.getStatus().isSuccess()) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "Successfully requested location updates"); } } else { Log.e(TAG, "Failed in requesting location updates, " + "status code: " + status.getStatusCode() + ", message: " + status.getStatusMessage()); } } }); } @Override protected void onPause() { super.onPause(); if (mGoogleApiClient.isConnected()) { LocationServices.FusedLocationApi .removeLocationUpdates(mGoogleApiClient, this); } mGoogleApiClient.disconnect(); } @Override public void onConnectionSuspended(int i) { if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "connection to location client suspended"); } }
Location data on wearable devices is obtained though the Google Play services location APIs. You use the FusedLocationProviderApi and its accompanying classes to obtain this data. To access location services, create an instance of GoogleApiClient, which is the main entry point for any of the Google Play services APIs.

This code snippet shows an implementation of an activity that implements the LocationListener interface.

#android #wear #androidWear #wearables #location #update #locationListener


Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.