没有找到心率传感器(LG Watch Urbane)

我正尝试使用MainActivity.java上的此代码访问我的LG Watch Urbane的心率传感器:

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"));

问题是我得到这个错误:

E/SensorManager: sensor or listener is null

发生该错误是因为没有与TYPE_HEART_RATE关联的传感器。 所以,我编写了一些代码,以便通过方法.getSensorList(Sensor.TYPE_ALL)获得完整的传感器列表,并且我得到了这个:

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

我没有在那里看到任何心率传感器,所以我不知道我必须使用什么类型的数字才能从中获取数据。

任何人都知道我做错了什么?

提前致谢。


确保您的应用程序已定义并授予Body Sensor权限。

确认:

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

存在于你的AndroidManifest.xml中

此外,请确保已通过检查手表上的权限设置授予权限:设置 - >权限 - >您的应用程序

链接地址: http://www.djcxy.com/p/32015.html

上一篇: Heart Rate Sensor not found (LG Watch Urbane)

下一篇: How to access heart rate sensor in Android Wearable?