Having trouble reading heart rate sensor from Moto 360 - Android Wear

后端 未结 6 872
悲&欢浪女
悲&欢浪女 2021-01-01 01:47

Has anyone successfully read the heart rate sensor from the Moto 360?

mSensorManager = ((SensorManager)getSystemService(SENSOR_SERVICE));
mHeartRateSensor =          


        
相关标签:
6条回答
  • 2021-01-01 02:35

    Along with making sure permissions are set for BODY_SENSORS in your manifest, make sure, after you install your app, that permissions are enabled:

    https://support.google.com/androidwear/answer/6321353?hl=en

    This one got me for a while...

    0 讨论(0)
  • 2021-01-01 02:47

    I had same issue with Moto360 and hers how I solved it.

    I tried all the solutions listed - re installing the app, upgrading the SDK but it dint work for me. I included permissions for body sensors in Manifest file. I couldn't see heart rate sensor in my list of available sensors. So I believe it was a permissions issue. API 23 onwards android uses a new permissions model.

    From this link : https://developer.android.com/training/articles/wear-permissions.html It says - "Note: For an app to use the new permissions model, it must specify a value of 23 for both uses-sdk-element and compileSdkVersion."

    I changed my gradel scripts to use both minsdk and compliledsdk as 23. Also added following to my app manifiest.

    <uses-sdk android:minSdkVersion="23"
                android:targetSdkVersion="23"
                 /> 
    

    And Now its working !!

    0 讨论(0)
  • 2021-01-01 02:47

    From android M you need to make sure that the user is enabling the permission at the first time the applications runs OR going manually to the app permission and enable it

    0 讨论(0)
  • 2021-01-01 02:48

    I was having the same problem while trying to poll the heart rate from a Moto 360, the sensor was null. Did the same as you to work out that the sensor available was the wellness sensor:

    sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
    Sensor sensor = sensorManager.getDefaultSensor(Sensor.TYPE_HEART_RATE);
    
    if (sensor == null) {
      List<Sensor> sensors = sensorManager.getSensorList(Sensor.TYPE_ALL);
      for (Sensor sensor1 : sensors) {
        Log.i(TAG, sensor1.getName() + ": " + availableSensor.getType());
      }
    }
    

    65538 seemed to be the correct type to use, so I used that.

    Wellness Passive Sensor 65538
    

    A Reddit thread I found suggested this was the correct route to go. I seemed to get readings from it, but they weren't reliable.

    With a little bit more research, I discovered an open source project that polls sensor data and displays it. This seems to only work sometimes, so I am treating the sensor APIs as unreliable and have temporarily parked my project. I'll revisit this again in a couple of months and update my answer if I believe the sensor APIs to be any more reliable.

    0 讨论(0)
  • 2021-01-01 02:51

    Sensor.TYPE_HEART_RATE is actually the correct ID. I had the same issue: the sensor was null even though I had the BODY_SENSORS permission in the manifest. I fixed it by removing the app, restarting the watch and by requesting the BODY_SENSORS permission at runtime (see https://developer.android.com/training/articles/wear-permissions.html). After that I got the system dialogue for the body sensor permission and I then started receiving updates from the sensor. I hope this helps.

    0 讨论(0)
  • 2021-01-01 02:53

    I am doing the same on my Moto 360 and I get the sensor and the heart rate. Did you put the permission for the body data:

    uses-permission android:name="android.permission.BODY_SENSORS"

    in your Manifest.xml?

    0 讨论(0)
提交回复
热议问题