4

I'm developing an app that will monitor a user's activity throughout the day, and when a particular activity is detected (i.e., driving) a notification will be triggered. The Google Play Services now supports ActivityRecognition, which really makes the task easier and more efficient (instead of messing with GPS/other sensors).

My question is - can I get the activity recognition to run entirely as a service? From my reading, it appears that the recognition must be initiated by an Activity (making the connection to the Play Services, triggering an intent, etc). That's fine when a user is interacting with the app, but if the phone reboots or the activity is otherwise closed, I need the service to keep on running in the background so it can continue to monitor users' activity and send pop-up notifications. Is there any way to do this? If so, are there any examples of this online? Thanks in advance!

  • 2
    Maybe off-topic, but this sounds really fishy... – takendarkk Aug 07 '14 at 03:07
  • @Takendarkk - I've got a perfectly legitimate application for this; for example, what about an app that will keep track of how long a user is walking throughout the day, and then pop-up notifications once exercise goals have been met? You don't want to have to manually start the app every day... – user1709255 Aug 07 '14 at 03:14
  • I just didn't see anyway for a user to turn this off. It seemed like you wanted a background service that would run without the user's knowledge and without the ability to turn it off, even if the user closed the app and restarted their phone. I didn't mean it _was_ fishy, only that it _sounded_ fishy. – takendarkk Aug 07 '14 at 03:25
  • @Takendarkk - Yes, the user would certainly have the ability to open the app to pause or turn off the service. – user1709255 Aug 07 '14 at 03:36
  • 1
    @Takendarkk "sounds fishy"... I know many useful situations when user-experience will increase then the phone "knows" what the user is doing... What else should be the benefit from activity-state "ON_BICYCLE" when the app is not in background?! do you think the user has got screen-on when detecting that he is riding a bike?! haha nice scenario... :P – Martin Pfeffer Dec 18 '14 at 20:13

0 Answers0