Class HealthSensors

java.lang.Object
com.codename1.health.sensors.HealthSensors

public class HealthSensors extends Object

Discovers and streams from standard Bluetooth SIG health sensors -- heart-rate straps, power meters, speed and cadence sensors, foot pods, thermometers, scales, blood-pressure cuffs and glucose meters.

Obtain one from Health.getSensors().

This works everywhere Bluetooth LE does

Unlike the rest of the health API, this layer needs no platform health store and no per-port implementation: it is built entirely on com.codename1.bluetooth.le, so it behaves identically on iOS, Android, the simulator, the desktop ports and -- where the browser exposes Web Bluetooth -- JavaScript. A desktop app that reports HealthAvailability.LOCAL_ONLY for the store can still stream a chest strap.

Quick start
HealthSensors sensors = Health.getInstance().getSensors();
SensorScanSettings settings = new SensorScanSettings()
        .addProfile(HealthSensorProfile.HEART_RATE)
        .setTimeoutMillis(15000);
SensorScan scan = sensors.startScan(settings, new SensorDiscoveryListener() {
    public void sensorDiscovered(HealthSensor sensor) {
        scan.stop();
        sensors.connect(sensor, HealthSensorProfile.HEART_RATE,
                new SensorSessionOptions())
              .onResult((session, err) -> { ... });
    }
    public void scanFailed(HealthException e) { Log.e(e); }
});
Permissions

These are Bluetooth operations, not health-store operations, so they need Bluetooth permission -- BluetoothPermission.SCAN and CONNECT -- and not a HealthKit entitlement or a Health Connect declaration. The build server makes the same distinction: an app that only uses this package is not treated as a health-data app.