Heart Rate Sensor not found (LG Watch Urbane)
Asked Answered
G

1

2

I'm trying to access to the heart rate sensor of my LG Watch Urbane using this code on MainActivity.java:

mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
mHeartRateSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_HEART_RATE);
boolean sensorRegistered = mSensorManager.registerListener(this, mHeartRateSensor, SensorManager.SENSOR_DELAY_NORMAL);
Log.d("Sensor Status:", " Sensor registered: " + (sensorRegistered ? "yes" : "no"));

The problem is that I get this error:

E/SensorManager: sensor or listener is null

That error happens because there isn't a sensor with TYPE_HEART_RATE associated. So, I wrote some code in order to get the full list of sensors with the method .getSensorList(Sensor.TYPE_ALL) and I got this:

03-14 02:56:43.221 2936-2936/? I/Sensor list: MPU6515 Accelerometer: 1
03-14 02:56:43.221 2936-2936/? I/Sensor list: AK8963 Magnetometer: 2
03-14 02:56:43.221 2936-2936/? I/Sensor list: AK8963 Magnetometer     Uncalibrated: 14
03-14 02:56:43.221 2936-2936/? I/Sensor list: MPU6515 Gyroscope: 4
03-14 02:56:43.221 2936-2936/? I/Sensor list: MPU6515 Gyroscope Uncalibrated: 16
03-14 02:56:43.221 2936-2936/? I/Sensor list: HSPPAD038 Pressure: 6
03-14 02:56:43.221 2936-2936/? I/Sensor list: MPU6515 Accelerometer -Wakeup Secondary: 1
03-14 02:56:43.221 2936-2936/? I/Sensor list: AK8963 Magnetometer -Wakeup Secondary: 2
03-14 02:56:43.221 2936-2936/? I/Sensor list: AK8963 Magnetometer Uncalibrated -Wakeup Secondary: 14
03-14 02:56:43.221 2936-2936/? I/Sensor list: MPU6515 Gyroscope -Wakeup Secondary: 4
03-14 02:56:43.221 2936-2936/? I/Sensor list: MPU6515 Gyroscope Uncalibrated -Wakeup Secondary: 16
03-14 02:56:43.221 2936-2936/? I/Sensor list: HSPPAD038 Pressure -Wakeup Secondary: 6
03-14 02:56:43.221 2936-2936/? I/Sensor list: Gravity: 9
03-14 02:56:43.221 2936-2936/? I/Sensor list: Linear Acceleration: 10
03-14 02:56:43.221 2936-2936/? I/Sensor list: Rotation Vector: 11
03-14 02:56:43.222 2936-2936/? I/Sensor list: Step Detector: 18
03-14 02:56:43.222 2936-2936/? I/Sensor list: Step Counter: 19
03-14 02:56:43.222 2936-2936/? I/Sensor list: Significant Motion Detector: 17
03-14 02:56:43.222 2936-2936/? I/Sensor list: Game Rotation Vector: 15
03-14 02:56:43.222 2936-2936/? I/Sensor list: GeoMagnetic Rotation Vector: 20
03-14 02:56:43.222 2936-2936/? I/Sensor list: Orientation: 3
03-14 02:56:43.222 2936-2936/? I/Sensor list: Tilt Detector: 22
03-14 02:56:43.222 2936-2936/? I/Sensor list: Gravity -Wakeup Secondary: 9
03-14 02:56:43.222 2936-2936/? I/Sensor list: Linear Acceleration -Wakeup Secondary: 10
03-14 02:56:43.222 2936-2936/? I/Sensor list: Rotation Vector -Wakeup Secondary: 11
03-14 02:56:43.222 2936-2936/? I/Sensor list: Step Detector -Wakeup Secondary: 18
03-14 02:56:43.222 2936-2936/? I/Sensor list: Step Counter -Wakeup Secondary: 19
03-14 02:56:43.222 2936-2936/? I/Sensor list: Game Rotation Vector -Wakeup Secondary: 15
03-14 02:56:43.222 2936-2936/? I/Sensor list: GeoMagnetic Rotation Vector -Wakeup Secondary: 20
03-14 02:56:43.222 2936-2936/? I/Sensor list: Orientation -Wakeup Secondary: 3
03-14 02:56:43.222 2936-2936/? I/Sensor list: Wrist Tilt Gesture: 26

I don't see any heart rate sensor there, so I don't know what type number I have to use in order to get data from it.

Anyone knows what am I doing wrong?

Thanks in advance.

Gailgaile answered 14/3, 2016 at 2:11 Comment(0)
D
5

Ensure that your application has defined and granted the Body Sensors permission.

Verify that:

<uses-permission android:name="android.permission.BODY_SENSORS"/>

is present in your AndroidManifest.xml

Also, ensure that the permission has been granted by checking the Permissions settings on the watch: Settings -> Permissions -> Your app

Doe answered 14/3, 2016 at 2:24 Comment(1)
Yes, I added that, but I just realised that I modified the mobile AndroidManifest.xml instead of wear AndroidManifest.xml. It works fine now, than you.Gailgaile

© 2022 - 2024 — McMap. All rights reserved.