我正在尝试在Android Wear设备(Moto 360
)上获取心率传感器数据。但是我不知道为什么无法识别TYPE_HEART_RATE
,并且应用程序显示sensor registered: no
。其他类型,例如STEP_COUNTER
返回yes
。
出什么问题了?!
public void onCreate() {
super.onCreate();
// register us as a sensor listener
mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
Sensor mHeartRateSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_HEART_RATE);
boolean res = mSensorManager.registerListener(this, mHeartRateSensor, SensorManager.SENSOR_DELAY_UI);
Log.d(LOG_TAG, " sensor registered: " + (res ? "yes" : "no"));
mGoogleApiClient = new GoogleApiClient.Builder(this).addApi(Wearable.API).build();
mGoogleApiClient.connect();
}
答案 0 :(得分:0)
我们应该转到智能手表的Settings-->Apps-->[App Name]-->Permissions
,以检查该权限是否已启用。默认情况下它是禁用的!