I have an application in which i want to navigate this way:
A -> B -> C
And from C launch a new activity called D, that goes to top and also clears the task, meaning that if i press back on D it goes to home screen.
If i understand it correctly this FLAG: FLAG_ACTIVITY_TASK_ON_HOME does this... but it's only on current APIs (11>).
I'm developing for Android 1.5> how can i also have this behaviour?
Thanks!
you are looking for this:
Intent intent = new Intent(activity, activityClass);
ComponentName cn = intent.getComponent();
Intent mainIntent = IntentCompat.makeRestartActivityTask(cn);
activity.startActivity(mainIntent);
use android compatibillity lib from google - found in the sdk.
or use finish()
You can use FLAG_ACTIVITY_CLEAR_TASK along with FLAG_ACTIVITY_NEW_TASK.
public static final int FLAG_ACTIVITY_CLEAR_TASK
Since: API Level 11
If set in an Intent passed to Context.startActivity(), this flag will cause any existing task that would be associated with the activity to be cleared before the activity is started. That is, the activity becomes the new root of an otherwise empty task, and any old activities are finished. This can only be used in conjunction with FLAG_ACTIVITY_NEW_TASK.
http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_CLEAR_TASK
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With