Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
475 views
in Technique[技术] by (71.8m points)

android - Get Heart Rate from "Sensor" Samsung Gear Live

How do I get the heartrate from the attached sensor on the Samsung Gear Live

I just tried to list all Sensors by

SensorManager  mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
List<Sensor> deviceSensors = mSensorManager.getSensorList(Sensor.TYPE_ALL);
for(Sensor s : deviceSensors){
    Log.i(TAG, "" + s.getName());
}

But I only get theses Sensors:

07-09 23:18:05.047    3269-3269/com.sample.soma.wapp I/MyActivity﹕ MPU6515 Acceleration Sensor
07-09 23:18:05.047    3269-3269/com.sample.soma.wapp I/MyActivity﹕ MPU6515 Gyroscope Sensor
07-09 23:18:05.057    3269-3269/com.sample.soma.wapp I/MyActivity﹕ AK8963C Magnetic field Sensor
07-09 23:18:05.057    3269-3269/com.sample.soma.wapp I/MyActivity﹕ AK8963C Magnetic Sensor UnCalibrated
07-09 23:18:05.057    3269-3269/com.sample.soma.wapp I/MyActivity﹕ SAMSUNG Step Detector Sensor
07-09 23:18:05.057    3269-3269/com.sample.soma.wapp I/MyActivity﹕ SAMSUNG Step Counter Sensor
07-09 23:18:05.057    3269-3269/com.sample.soma.wapp I/MyActivity﹕ SAMSUNG Significant Motion Sensor
07-09 23:18:05.057    3269-3269/com.sample.soma.wapp I/MyActivity﹕ SAMSUNG Game Rotation Vector
07-09 23:18:05.057    3269-3269/com.sample.soma.wapp I/MyActivity﹕ SAMSUNG Tilt Wake Sensor
07-09 23:18:05.057    3269-3269/com.sample.soma.wapp I/MyActivity﹕ MPL Rotation Vector
07-09 23:18:05.057    3269-3269/com.sample.soma.wapp I/MyActivity﹕ MPL Orientation
07-09 23:18:05.067    3269-3269/com.sample.soma.wapp I/MyActivity﹕ MPL Gravity
07-09 23:18:05.067    3269-3269/com.sample.soma.wapp I/MyActivity﹕ MPL Linear Accelration

How do they measure the heart rate? Are some parts of the Android W Apps open sourced so I can have a look at them?

Thanks and Greets.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Here is a gist that shows how to read the heart rate sensor.

The meat of it is:

SensorManager mSensorManager = ((SensorManager)getSystemService(SENSOR_SERVICE));
Sensor mHeartRateSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_HEART_RATE);
Sensor mStepCountSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER);
Sensor mStepDetectSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_STEP_DETECTOR);

mSensorManager.registerListener(this, mHeartRateSensor, SensorManager.SENSOR_DELAY_NORMAL);
mSensorManager.registerListener(this, mStepCountSensor, SensorManager.SENSOR_DELAY_NORMAL);
mSensorManager.registerListener(this, mStepDetectSensor, SensorManager.SENSOR_DELAY_NORMAL);

You will also need the following entry in the AndroidManifest.xml

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...