/* * Subscribes to distance. */ private void subscribeToDistance() { if ((mGoogleApiClient != null) && (mGoogleApiClient.isConnecting())) { Fitness.RecordingApi.subscribe(mGoogleApiClient, DataType.TYPE_DISTANCE_DELTA) .setResultCallback( new ResultCallback<Status>() { @Override public void onResult(Status status) { if (status.isSuccess()) { if (status.getStatusCode() == FitnessStatusCodes.SUCCESS_ALREADY_SUBSCRIBED) { Log.i(TAG, "Existing subscription for activity detected."); } else { Log.i(TAG, "Successfully subscribed!"); } } else { Log.i(TAG, "There was a problem subscribing."); } } }); } }
private void showSubscriptions() { Fitness.RecordingApi.listSubscriptions(mGoogleApiClient) .setResultCallback(mListSubscriptionsResultCallback); }
@Override public void onConnected(@Nullable Bundle bundle) { Fitness.RecordingApi.subscribe(mGoogleApiClient, DataType.TYPE_STEP_COUNT_DELTA) .setResultCallback(mSubscribeResultCallback); }
private void cancelSubscriptions() { Fitness.RecordingApi.unsubscribe(mGoogleApiClient, DataType.TYPE_STEP_COUNT_DELTA) .setResultCallback(mCancelSubscriptionResultCallback); }