How to reset perform all actions and start a new one?

I have an application in which I want to navigate this path:

A → B → C

And from C, a new action is launched called D, which goes to the first place, and also clears the task, which means that if I return to D, it will go to the main screen.

If I understand this FLAG correctly: FLAG_ACTIVITY_TASK_ON_HOME does this ... but it is only in the current APIs (11>).

I am developing for Android 1.5> how can I also have this behavior?

Thank!

+3
source share
3 answers

you are looking for:

Intent intent = new Intent(activity, activityClass);
ComponentName cn = intent.getComponent();
Intent mainIntent = IntentCompat.makeRestartActivityTask(cn);
activity.startActivity(mainIntent);

use android compatibillity lib from google - find in sdk.

or use finish()

+6
source

You can use FLAG_ACTIVITY_CLEAR_TASKwith FLAG_ACTIVITY_NEW_TASK.

public static final int FLAG_ACTIVITY_CLEAR_TASK

: API 11

Intent, Context.startActivity(), , , . , , . FLAG_ACTIVITY_NEW_TASK.

http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_CLEAR_TASK

+2

fooobar.com/questions/372909/..., 1,5 > , API-.

"" API, @aromero .

0

All Articles