Q:

Android auto start activity (app starts twice)

I would like to run my application when the boot up of my device has finished.
For this I have found some helpful code in the internet:
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);  
        } 
    }
}

And the Manifest entry:
    <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> 

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!

A:

So...
after long long testing I found out that the problem should be my physical tablet (asus eee pad transfortem android version 3.2.1).
Because I have tried it in the emulator (android version 3.2) and there the source code I posted (on the top of this thread) worked quite well.
No start up twice of the app and no errors. 
Even if you remove the "pushIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);" code it works.
So it seems that I have to wait for an update (maybe on android 4.0). 
I hope this helps somebody, who has the same problem.

