I'm developing an Android 2.2 application.
I'm very new on Android, and I see that if Iaunch a new Intent from an activity, this activity goes to paused state.
If I want that user can't goes back to this previous activity, what must I do? May I kill this previous a开发者_如何学编程ctivity with finish?
UPDATE
An example:A, B C and D are activities. A is the first activity.
A launches B, and B launches C, and C launches D.
I want to close or kill activity B and C when D is launched.
Thanks.
You can use your intent to startActivity like normal and follow the startActivity with
finish();
If you do this on your hypothetical activity B, you can hit the hardware back button in C and it'll take you directly to A.
You might want to rework your design. What if you have A call startActivityForResult(B, 0), and when B would have launched C, instead setResult and finish. Back in A, onActivityResult gets called, with the result you set. You can use that result as a message for A to now start the activity C.
See if that helps - http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_CLEAR_TOP (This and other flags)
And also you must invoke
finish();
精彩评论