2

I am trying to connect my application with Samsung health, but i am unable to connect to the HealthDataStore.

  • I have enabled sHealth in developer mode.
  • I have added permission for the meta data.
HealthDataStore mStore = new HealthDataStore(DashboardListActivity.this,mConnectionListener);
        mStore.connectService();

    private final HealthDataStore.ConnectionListener mConnectionListener = new HealthDataStore.ConnectionListener() {
        @Override
        public void onConnected() {

            Log.d(TAG, "Health data service is connected.");
            /*HealthPermissionManager pmsManager = new HealthPermissionManager(mStore);
            Map<HealthPermissionManager.PermissionKey, Boolean> resultMap = pmsManager.isPermissionAcquired(mKeySet);

            if (resultMap.containsValue(Boolean.FALSE)) {
                // Request the permission for reading step counts if it is not acquired
                pmsManager.requestPermissions(mKeySet, mActivity).setResultListener(mPermissionListener);
            } else {
                // Get the current step count and display it
                // ...
                HealthDataResolver.AggregateRequest request = (HealthDataResolver.AggregateRequest) new HealthDataResolver.AggregateRequest.Builder()
                        .setDataType(HealthConstants.Exercise.HEALTH_DATA_TYPE);
            }*/

        }

        @Override
        public void onConnectionFailed(HealthConnectionErrorResult healthConnectionErrorResult) {

            Log.d(TAG, "Health data service is not available.");
            //showConnectionFailureDialog(healthConnectionErrorResult);
        }

        @Override
        public void onDisconnected() {
            Log.d(TAG, "Health data service is not Disconnected.");

        }
    };

I am always getting the onConnectionfailed, its not hitting the connection success.

Dvyn Resh
  • 980
  • 1
  • 6
  • 14
ridder22
  • 21
  • 4

0 Answers0