For this I have found some helpful code in the internet:
Using java Syntax Highlighting
- public class MyBootCompleteReceiver extends BroadcastReceiver
- {
- @Override
- public void onReceive(Context context, Intent intent)
- {
- if(intent.getAction() != null && intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED))
- {
- Intent pushIntent = new Intent(context, MainActivity.class);
- pushIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.startActivity(pushIntent);
- }
- }
- }
Parsed in 0.032 seconds, using GeSHi 1.0.8.4
And the Manifest entry:
Using java Syntax Highlighting
- <receiver android:name="MyBootCompleteReceiver" android:enabled="true" android:exported="false" 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>
Parsed in 0.032 seconds, using GeSHi 1.0.8.4
Now if I boot up my device the application seems to start up twice.
Then I tried to replace the "NEW_TASK" Flag with the "REORDER_TO_FRONT" (I have also read this in the internet) but if i do so, my application crashes on boot up.
Also if I remove all flags, it crashes too.
Hope you can help!



