androidwear-osandroid-wear-data-apiandroid-wear-2.0

How to get sleep data DIRECTLY from Wear OS?


I am new to Wear OS development, and am trying to get user's sleep duration.

I've managed to get sleep data from other smartbands using raw BLE stack, but I don't know how should I gather sleep data from Wear OS?.

I've searched a bit in the web, and most people suggest to use Google Fit API, but in my case, I can't depend on external APIs.

So these are my questions

1) Is there anyway I can get sleep data from the Wear OS direclty ? If Yes, How?

If No,

2) Should I build a sleep tracker myself (by analyzing watch's movement and heart rate) ?


Solution

  • 1) No. WearOS is just a system that provides a runtime environment, maybe along with some base functions. Sleep data is not a basic function, while the raw sensor data is yes.

    2) Yes. If you don't want to rely on GoogleFit or other 3rd part API. The only way is to fetch the raw sensor data and analyze them your self.