Xamarin Android HeartRate Sensor Activation

184 Views Asked by At

I want to make a simple App for my Samsung Watch 4 Wear OS but I'm struggle to get the sensor for the heart rate up an running in my xamarin android solution.

What I tried so far is:

'''

        using Android.Hardware;

        SensorManager sm = (SensorManager)this.GetSystemService(SensorService);
        if (sm.GetSensorList(SensorType.HeartRate).Count != 0)
        {
            Sensor s = sm.GetDefaultSensor(SensorType.HeartRate);
            sm.RegisterListener(this, s, SensorDelay.Fastest);
        }

...

        public void OnSensorChanged(SensorEvent e)
        {
           // Do something...
        }

'''

But I think I have to activate/start the sensor itself first but how? I tried with the Android emulator and with the smart watch device but no luck.

I'm working with VS2022 / API Level 31.

Thanks for some hints!

0

There are 0 best solutions below