I want to start my MainActivity, in android 2.3, it will not start, but in Jelly Bean it works. I get no error, nothing happens!
I've noticed when I use putExtra, then it does not work. Is there a reason?
start MainActivity
final ComponentName cn = new ComponentName("de.application.ui", "de.application.ui.MainActivity");
Intent intent = IntentCompat.makeRestartActivityTask(cn);
intent.putExtra("de.application.exit", true); // I have this line in it yet
activity.startActivity(intent);
Manifest
<activity
android:theme="@style/Theme"
android:name=".ui.MainActivity"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
My solution that works.
start MainActivity
Intent intent = new Intent(activity, MainActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK|Intent.FLAG_ACTIVITY_CLEAR_TASK|Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("de.application.exit", true);
activity.finish();
activity.startActivity(intent);
Manifest
<activity
android:theme="@style/Theme"
android:name=".ui.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>