How to start an application at bootup in ANDROID?

By | October 4, 2010

This snippet starts an Application automatically after the android-os booted up.
[java]
String url = "url";
Intent intent1 = new Intent(Intent.ACTION_VIEW);
intent1.setData(Uri.parse(url));
startActivity(intent1);
[/java]
in AndroidManifest.xml (application-part):
[xml]
<receiver android:enabled="true" android:name=".BootUpReceiver"
android:permission="android.permission.RECEIVE_BOOT_COMPLETED">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
[..]
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
[..]
[/xml]

[java]
public class BootUpReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
Intent i = new Intent(context, MyActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
[/java]

2 thoughts on “How to start an application at bootup in ANDROID?

  1. Pingback: How to start an application at bootup in ANDROID? » Ideal Codes

  2. Pingback: Rastreamento de celular android via gps | FelipeBastosWeb

Leave a Reply

Your email address will not be published. Required fields are marked *