Activity Recognition API does not work continuously

血红的双手。 提交于 2019-12-02 07:17:31

问题


I'm testing Activity Recognition API in 2 apps : Google sample code and implementation of this code in my app.

The problem is both apps keeps getting activity recognition fine but after a few hours the intent service stops and i'm not getting any activity recognition from both of them.

Any idea why the intent service stops even though i've tested geofencing api with intent service and it's working forever without stopping?


回答1:


Your IntentService might "stop", I would say "fall asleep" because of:

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.

Basically it should be the case for most of the devices with API >= 20.

Please find more here.

Unfortunately, you can only request activity updates and it is impossible to force ActivityRecognitionApi to continuously give current activity even if it is "still" for some mysterious "extended period of time".

In my opinion, it would much more convenient if this feature of ActivityRecognitionApi was configurable.



来源:https://stackoverflow.com/questions/29975230/activity-recognition-api-does-not-work-continuously

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!