Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect android watch is worn or not on AW2.0

Tags:

wear-os

Android wear 2.0 screen can be automatically locked right after it is taken off and the heart rate app / watch face would not work when it is not worn.

I am wondering is there any way to get current wear worn state without starting a service to listen to wear activity?

I tried to get the heart rate sensor accuracy, but I don't think it is a good way because I can not always get the right result in this way immediately.

Is there any system or gms API to get a current worn state synchronously?

like image 348
zhlicen Avatar asked Nov 25 '25 07:11

zhlicen


1 Answers

On watches with an off-body sensor (which lock immediately when not worn), you can check for the existence of the wakeup sensor TYPE_LOW_LATENCY_OFF_BODY_DETECT. This is only a public API in O+, but you can just use the actual value for N MR1 and below.

SensorManager sensorManager = 
    (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
boolean hasSensor = sensorManger.getDefaultSensor(34, true /* wakeup */) != null;

On watches without an off-body sensor (which don't lock immediately), your best bet is probably some sort of activity recognition, though there don't seem to be any public off-body activities that can be detected by Google APIs (see here).

like image 114
z153 Avatar answered Nov 28 '25 16:11

z153



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!