I'm going to use Activity Recognition API to do some optimizations on an App. In short I need to know when a device is STILL. But I do not want the App became battery draining by leaving sensors always on.
On is reported:
To conserve battery, activity reporting may stop when the device is 'STILL' for an extended period of time. It will resume once the device moves again. This only happens on devices that support the Sensor.TYPE_SIGNIFICANT_MOTION hardware.
I would register to ActivityRecognitionAPI only for devices that support significant motion detection by HW. But I cannot find a way to check when this support exists.
Using:
SensorManager sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
Sensor sensor = sensorManager.getDefaultSensor(Sensor.TYPE_SIGNIFICANT_MOTION);
boolean supportSignificantMotion = (sensor != null);
does not discriminate if support is by HW or by SW (on most devices this may be implemented just by software on accelerometer sensor).
Does anyone know if is it possibile to perform that check?
Thanks
I was just checking around the Activity Recognition API and I had the same question.
As far as I know, there is no way to check if it is a hardware or a software sensor, but as I read at https://source.android.com/devices/sensors/sensor-types.html#significant_motion, I guess that all the significant motion sensors are software. Maybe that documentation you reported is a typo.
I think that it should work as long as it is a wake up sensor.
The thing that confused me is the statement
getDefaultSensor(SENSOR_TYPE_SIGNIFICANT_MOTION) returns a non-wake-up sensor
Non wake-up sensors won't wake up the device, as described in http://developer.android.com/intl/pt-br/reference/android/hardware/Sensor.html#isWakeUpSensor()
But in the documentation of significant motion sensor (http://developer.android.com/intl/pt-br/reference/android/hardware/Sensor.html#TYPE_SIGNIFICANT_MOTION) says that this is a wake up sensor.
Maybe it depends on the software implementation? If so, it would be possible to check with http://developer.android.com/intl/pt-br/reference/android/hardware/Sensor.html#isWakeUpSensor()
I'm still searching and testing. If I get any news, I'll update the answer.
Let me know if you got any news aswell, please.
PS: I know this isn't really an answer, but it was too long to be a comment
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With