Search code examples
androidwear-osmoto-360

How to access heart rate sensor in Android Wearable?


I am having problems accessing heart rate sensor on Moto 360.

I tried following things :

Sensor mHeartRateSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_HEART_RATE);
mSensorManager.registerListener(this, mHeartRateSensor, SensorManager.SENSOR_DELAY_NORMAL);

and then implement SensorEventListener interface :

@Override
public void onSensorChanged(SensorEvent event) {

        String TAG = "tag";
        Log.i(TAG, "--------------------------");
        Log.i(TAG, msg);
        Log.i(TAG, ""+ event.sensor.getType());
        Log.i("live","--------------");

And what is strange to me I do not get any messages at all (not only heart rate).

Also I tried listing all sensors and it does not show Heart rate sensor on the list.

Of course I've added persmissions

 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.watchtest" >

<uses-feature android:name="android.hardware.type.watch" />
<uses-permission android:name="android.permission.BODY_SENSORS" />

Any ideas ?

thanks.

w.


Solution

  • As @Kent and @Murphy suggested, updated SDK was the solution. In my case I needed to drop the project and create new from scratch as even with updated SDK old one did not work.