0

In the demo video provided by google, it is said that you don't need to keep a service running to receive updates on activity recognition. But all code examples I could find show that you need to register ActivityRecognition in MainActivity for it to work.

How can I make Activity Recognition independent of application lifecycle? For e.g. If a user is jogging, show him a notification to record his walk?

Can it work similar to a broadcast receiver which is called as soon a user is connected to wifi?

Shubham Kanodia
  • 6,036
  • 3
  • 32
  • 46

1 Answers1

0

As an example you could subscribe to ActivityRecognition events when your phone booted successfully. You only need to do it once. After that the PendingIntent is called in the specified interval and you do not need to have a service running all the time in the background.

Frederik Schweiger
  • 8,472
  • 6
  • 25
  • 27