找不到心率传感器(LG Watch Urbane) [英] Heart Rate Sensor not found (LG Watch Urbane)
问题描述
我正在尝试使用MainActivity.java上的以下代码访问LG Watch Urbane的心率传感器:
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"));
问题是我收到此错误:
E/SensorManager: sensor or listener is null
发生此错误是因为没有与TYPE_HEART_RATE相关联的传感器.因此,我编写了一些代码,以使用方法.getSensorList(Sensor.TYPE_ALL)来获取传感器的完整列表,我得到了:
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?
谢谢.
推荐答案
确保您的应用程序已定义并授予身体传感器"权限.
Ensure that your application has defined and granted the Body Sensors permission.
验证:
<uses-permission android:name="android.permission.BODY_SENSORS"/>
存在于您的AndroidManifest.xml
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
这篇关于找不到心率传感器(LG Watch Urbane)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!