2

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.

Jerome
  • 1,749
  • 1
  • 14
  • 40

1 Answers1

2

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.

ianhanniballake
  • 191,609
  • 30
  • 470
  • 443
  • Thanks for your reply. but I use the pendingIntent to trigger a specific intentservice, how can another app's request start my Service? It will largely increase the battery consumption if interval is very short,isn't it? – Jerome Jan 27 '14 at 06:25
  • @Jerome - if you run your IntentService and it does a considerable amount of work and you don't ignore faster interval updates, then sure that will take up additional battery usage, but the lower interval and low battery life because of it is already there, whether your app is running or not (due to the other app). – ianhanniballake Jan 27 '14 at 06:34
  • i see. But I can't find out why the interval on Nexus 5 is always 5s while the interval in my code doesn't work on Galaxy S4 mini until I restart the phone. – Jerome Jan 27 '14 at 09:01