1

I'm trying to write an Android service, which starts on boot and works in the background periodically. I have defined the BroadcastReceiver of mine, added the right permissions and all the necessary stuff in manifest.

When I install the APK on my phone and reboot, nothing happens, the program is there in the installed apps section, but not running.

I've seen a user comment stating that "standalone" services are disabled (for security reasons?) since Android 3.1 but I couldn't verify this information anywhere.

Anyone could give me a clear view about this? Without that, I don't know how to proceed: debug or change plans.

Thank you in advance!

Peter
  • 323
  • 1
  • 16
  • 46
  • Have you checked http://stackoverflow.com/questions/2784441/trying-to-start-a-service-on-boot-on-android ? – matiash May 25 '14 at 19:10
  • 3
    It's a "security" feature. You can't run any broadcast receivers until at least one activity in your apk has been run. Just give your apk one activity and run it when you install, the next reboot you should be able to start your BOOT_COMPLETED receiver. – Gabe Sechan May 25 '14 at 19:27

1 Answers1

3

Just after the first the first installation of a package, the application is in a "stopped state" preventing it to execute any code for security reasons.

The app loses this particular "stopped state" as soon as the user launch the app explicitly for the first time.

Ananth
  • 2,597
  • 1
  • 29
  • 39
ben75
  • 29,217
  • 10
  • 88
  • 134