6

I'm looking at the description for the Plan B app here: https://play.google.com/store/apps/details?id=com.lookout.labs.planb. It says it will start automatically after installation. How do you configure an app to do this?

Phillip
  • 5,366
  • 10
  • 43
  • 62

1 Answers1

8

Register to receive common intents. One especially suitable for your purpose is:

"android.intent.action.PACKAGE_ADDED"

You might also listen for other intents such as BOOT_COMPLETED, etc.

Edit: According to another Stack Overflow answer, You can't run your own application immediately after it's installed. You must register for other intents as I suggested. Something to note is that you app will require user permission to receive the BOOT_COMPLETED intent.

Update: As pointed out by zapl, post 4.0 you cannot do anything after install now until the user explicitly launches your app.

dcow
  • 7,765
  • 3
  • 45
  • 65
  • Thanks David. The PACKAGE_ADDED listener has to be in a separate app installed and run manually beforehand though, right? – Phillip May 14 '12 at 17:05
  • 8
    As of Android 4.0 you don't receive any broadcasts unless the user starts your app once manually. The app is in deactivated state directly after install (and no code in there is started, no receiver or service registered etc) to stop apps you just downloaded but never used from using up system resources. Once activated through user interaction it works like before. – zapl May 14 '12 at 17:28