The topic pretty much says it all.
Android 2.2: How to make an app to run automaticly on startup & how to make an app start another app
Asked
Active
Viewed 5,130 times
2 Answers
4
Use BroadcastReceiver
that receives Intent of action BOOT_COMPLETED
.
in onReceive() method create an Intent for your activity:
@Override
public void onReceive(Context context, Intent intent) {
Intent myIntent = new Intent(context, YourActivity.class);
context.startActivity(myIntent);
}

Vladimir Ivanov
- 42,730
- 18
- 77
- 103
-
I have added the permissions, but where do i put this code? Sorry, but i started developing apps today :) Thanks – Johan Dec 29 '10 at 14:30
-
in your BroadcastReceiver of course. See the link. Sorry it is in russian, but the two code samples are sufficient. http://ondroid.info/primer-ispolzovaniya-broadcast-receiver-v-android/ – Vladimir Ivanov Dec 29 '10 at 14:52
3
For the application on startup, you need to add the permission
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
to your manifest. Then do as Vladimir wrote.
For starting another app, you need to know the (hopefully official) intent to start it. Otherwise see my reply on question calling an activity that is in another package(android)
For example, starting the LastFM app would be like this:
final Intent i = new Intent("android.intent.action.MAIN");
i.setComponent(new ComponentName("fm.last.android","fm.last.android.LastFm"));
startActivity(i);

Community
- 1
- 1

Mathias Conradt
- 28,420
- 21
- 138
- 192
-
Okay, but where do i find the "fm.last.android" and "fm.last.android.LastFm" in an app that i want to run? The Doplhin web browser for example. – Johan Dec 29 '10 at 14:29
-
Open the dolphin browser regularly and while you do that, check the logcat via 'adb shell logcat', you will then see in the log which intent is called. Then you use the values there in your ComponentName. Which dolphin you want? HD, mini or the regular one? – Mathias Conradt Dec 29 '10 at 15:46
-
For Dolphin HD, try: new ComponentName("mobi.mgeek.TunnyBrowser","mobi.mgeek.TunnyBrowser.BrowserActivity") - for regular Dolphin, try: new ComponentName("com.mgeek.android.DolphinBrowser.Browser","com.mgeek.android.DolphinBrowser.Browser.BrowserActivity") – Mathias Conradt Dec 29 '10 at 15:55