Reputation: 327
I have an android app that has a ui but also has several service classes that run in the background and do things like monitor location, texts, ect. The services are initiated when the app starts from my main activity (after the configuration is loaded from a web server- initialed by main activity's "onCreate"). However, I want this configuration to be loaded and the services to start when the phone is turned on, and since the main activity initially doesn't launch until the user tells it to, the services are not started until this point. Does my main activity (one specified in launcher) need to extend something other than "activity" so that these web service calls can be made and services started as soon as phone turned on though not necessarily showing the ui? Thanks
Upvotes: 1
Views: 122
Reputation: 2039
I think what you need is a broadcast receiver and the android permission RECEIVE_BOOT_COMPLETED.
Check out this post: Trying to start a service on boot on Android
Good Luck!
Upvotes: 1