1

Moto 360我正在尝试在我的 Android Wear 设备 ( )上获取心率传感器数据。但我不知道为什么TYPE_HEART_RATE无法识别,应用程序显示sensor registered: no. 其他类型,如STEP_COUNTERreturn 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();
    }
4

1 回答 1

0

我们应该去智能手表Settings-->Apps-->[App Name]-->Permissions那里检查是否启用了该权限。默认是禁用的!

于 2018-10-30T19:55:17.607 回答