12

I want to identify if the Sensor used for Activity Recognition works when device screen is off.

Activity Recognition stops as soon as Device screen is turned OFF. I searched for it and found that sensor does not work when screen is OFF to save the battery.

So there is a method to identify such sensors by isWakeUpSensor(), but isWakeUpSensor() is applicable from API 21.

How can I make it work on API 14 onward. Identify sensor before starting Activity Recognition. Same as application "Moves" does

Sagar Patil
  • 1,400
  • 15
  • 29

1 Answers1

9

After a little bit of searching I found this documentation which states

Up to KitKat, whether a sensor was a wake-up or a non-wake-up sensor was dictated by the sensor type: most were non-wake-up sensors, with the exception of the proximity sensor and the significant motion detector.

On the other hand, the significant motion detector page says

Implement only the wake-up version of this sensor. getDefaultSensor(SENSOR_TYPE_SIGNIFICANT_MOTION) returns a non-wake-up sensor

which confuses me. It is, however, a composite sensor, which means that it's wake-up-ness depends on the underlying actual sensors (I would imagine).

More research into this suggests that significant motion detector was added in Android 4.3 (API 18), so you're left with the proximity sensor for available wake-up sensors in API 14 devices, which is primarily intended to be used to turn the screen on and off when making phone calls.

Seems to me like there is no way to do exactly what you have in mind without a wake lock.

Zharf
  • 2,638
  • 25
  • 26
  • 1
    Activity Recognition stops as soon as Device screen is turned OFF. I searched for it and found that sensor does not work when screen is OFF to save the battery. This happens only on few devices. So how to IDENTIFY that the activity recognition will stop when device screen is off. – Sagar Patil Aug 25 '15 at 06:34
  • I don't think you can, at least without some kind of heurestics that try to follow activity recognition after the screen has been turned off. The sensors prior to API 21 just don't provide that information – Zharf Aug 25 '15 at 07:33
  • If you check "Moves" application, after installing it and on the first run it immediately says that the device does not support Activity recognition when device screen is off. If they can identify there must me some technique to identify below API lvl 21 – Sagar Patil Aug 25 '15 at 10:54
  • The top review for me describes the same problem as you're having... they might have some sort of blacklist of devices where it doesn't work but it's not very reliable either. – Zharf Aug 25 '15 at 11:07