Pregunta

As described in the title, my problem is can't control the activity recognition request properly. My code like this:

arclient.requestActivityUpdates(ACTIVITY_DETECT_INTERVAL, pIntent);

the ACTIVITY_DETECT_INTERVAL =2*60*1000 (2 mins),

but the log shows

01-27 12:21:49.412: I/ActivityRecognitionService(5458): Still   92
01-27 12:21:54.462: I/ActivityRecognitionService(5458): Still   92
01-27 12:21:59.492: I/ActivityRecognitionService(5458): Still   69
01-27 12:22:04.562: I/ActivityRecognitionService(5458): Still   76
01-27 12:22:09.662: I/ActivityRecognitionService(5458): Still   76
01-27 12:22:14.592: I/ActivityRecognitionService(5458): Still   92
01-27 12:22:19.612: I/ActivityRecognitionService(5458): Still   77
01-27 12:22:24.622: I/ActivityRecognitionService(5458): Still   92
01-27 12:22:29.672: I/ActivityRecognitionService(5458): Still   92
01-27 12:22:34.892: I/ActivityRecognitionService(5458): Still   85
01-27 12:22:39.812: I/ActivityRecognitionService(5458): Still   92

it turns out the interval is always 5 seconds . Who can give me a hand, thanks in advance.

¿Fue útil?

Solución

Per the requestActivityUpdates documentation:

Activities may be received more frequently than the detectionIntervalMillis parameter if another application has also requested activity updates at a faster rate. It may also receive updates faster when the activity detection service receives a signal that the current activity may change, such as if the device has been still for a long period of time and is then unplugged from a phone charger.

You can certainly filter out events within your own application (assuming you store the last time you received an event and then ignoring events between then and 2 minutes after that time), but there is no way to limit the amount of incoming activity updates beyond what the most power hungry app on your phone requests or your request, whatever is larger.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top