From what I read in other posts and in Google documentation, You can not run some code after app got installed and before the user opens it. Second approach is to make broadcast receiver that receive an intent (like SMS received) and then execute your code inside onReceive
method but the problem here is that the app will be in stopped state until the user first opens it then it can receive any intent like SMS received for example. I found an app that does this androidlost.com, you install the app remotely, then send SMS remotely and so get some code executed in OnReceive method. Any way how this can be done ?

- 4,442
- 2
- 40
- 65
2 Answers
According to answers and comments provided here
applications installed on the /system partition are not subject to being placed into the "stopped" state after installation. and it can immediately receive broadcast intents.
How to get the application installed to /system/app ??
comment by Olle
As long as you have the same package name and signing you can update a system app. The update will be placed on the data partition but still have the "system" status since a previous version is available on the system partition. – Olle Sep 21 '12 at 10:39
UPDATE
Another thing you can do is add a BOOT_COMPLETED
intent and ask the user to reboot the phone or if the device is rooted you can get the root permission and reboot the device and start the app that way
-
I did not get it. How to make my app installed in /system directory ?. I'm supposed to upload the app to Android Market and the user will install it from there. Is there any flags or so to use to make it installed in /System directory? – MSaudi Jan 22 '14 at 06:11
-
As i used to work around with the good old HTC Dream/G1 i found that most of the(or all?) the apps gets installed in the /system/app folder in android upto Gingerbread,it was actually a security loophole and got fixed in honeycomb – insomniac Jan 22 '14 at 06:16
-
So we are still locked. No solution here. – MSaudi Jan 22 '14 at 06:22
-
I don't need any user interaction to start the app. If I will ask the user to reboot it will be easier to ask him to open the app. – MSaudi Jan 22 '14 at 07:11
-
well,you are stuck then – insomniac Jan 22 '14 at 07:28
Recently installed application on the devices which are having android version lower than 3.1
will be able to receive
the broadcasts.
But in the case of the devices having higher version than 3.1
, they will be in stopped state and they will not be able to receive
any broadcasts because system adds FLAG_EXCLUDE_STOPPED_PACKAGES to all broadcast intents
.
So even the AndroidLost
will not be able to receive broadcasts in this case.
Reference : Launch Controls

- 15,348
- 6
- 48
- 57
-
I tested Android Lost in my device Samsung ACE3, Android 4.2.2 and It worked and that what makes me confused ! I installed the application remotely and send Activation SMS and then instantly I could administrate the phone. – MSaudi Jan 27 '14 at 09:36