Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you get an Android app to automatically run after download and installation?

Tags:

android

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?

like image 910
Phillip Avatar asked May 14 '12 16:05

Phillip


1 Answers

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.

like image 111
dcow Avatar answered Sep 27 '22 23:09

dcow