Java tutorial
//package com.java2s; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; public class Main { private static SensorManager sensorManager; public static boolean startHeartMonitor(SensorEventListener listener, int delay) { Sensor heartSensor = getSensor(Sensor.TYPE_HEART_RATE); if (heartSensor != null) { sensorManager.registerListener(new SensorEventListener() { @Override public void onSensorChanged(SensorEvent event) { } @Override public void onAccuracyChanged(Sensor sensor, int accuracy) { } }, heartSensor, delay); } return false; } public static Sensor getSensor(int type) { return sensorManager.getDefaultSensor(type); } }