Max Testing
Max Testing

Reputation: 145

ActivityRecognitionAPI keeps sending pending intents to the service

I am using ActivityRecognitionAPI in Android 4.4.2 to detect activities on the phone. I am using this code to implement this.

The code requests for activity updates after every 15 seconds (I know, the documentation says that this is the upper bound but I have only this app on my device which requests this information) but the app keeps sending intents after every 3-4 seconds. I was thinking to save some battery based on activity but I guess, it would be draining more of it. Any suggestions for improvement?

Trimmed version of logs:

06-01 19:58:19.774:  Still 100%
06-01 19:58:23.414:  ACCCCCCCCCCTOVOTTTTTTESSS detected
06-01 19:58:27.104:  ACCCCCCCCCCTOVOTTTTTTESSS detected
06-01 19:58:27.104:  Still 100%
06-01 19:58:30.744:  ACCCCCCCCCCTOVOTTTTTTESSS detected
06-01 19:58:30.744:  Still 100%
06-01 19:58:34.424:  ACCCCCCCCCCTOVOTTTTTTESSS detected
06-01 19:58:34.424:  Still 100%
06-01 19:58:38.064:  ACCCCCCCCCCTOVOTTTTTTESSS detected
06-01 19:58:38.064:  Still 100%
06-01 19:58:41.684:  ACCCCCCCCCCTOVOTTTTTTESSS detected
06-01 19:58:41.684:  Still 100%
06-01 19:58:46.544:  ACCCCCCCCCCTOVOTTTTTTESSS detected
06-01 19:58:46.544:  Still 100%
06-01 19:58:50.224:  ACCCCCCCCCCTOVOTTTTTTESSS detected
06-01 19:58:50.224:  Still 100%

Upvotes: 0

Views: 109

Answers (1)

MikeWallaceDev
MikeWallaceDev

Reputation: 1468

As per the 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.

So the update detectionIntervalMillis parameter is more of a guideline.

Upvotes: 1

Related Questions