Mike,

You need to think of activities like a stack of cards. If you open
one, it will be placed on top of the pack. So if you want to open a
new activity from Activity B, just do use startActivity() as normal.

Activity A ---> Activity B --> Activity C

When you close Activity C, do a setResult(RESULT_CANCELLED) followed
by finish() just like I described for Activity B. Activity B will
handle the onActivityResult(), where you tell it to do the same thing
again. This way you are popping the activities off the stack
one-by-one, when there are no more activities left, the app will
close. To the user, this will appear as though Activity A and Activity
B had been closed when Activity C opened.

Your second option, which I did not think of before, is to add the
android:noHistory="true" attribute to Activity A and Activity B in
your AndroidManifest.xml. I don't have much experience with this flag,
but my understanding is that it will close the current activity when
another one is opened. The first approach will give you more control,
but this attribute might be simpler:
http://developer.android.com/intl/fr/guide/topics/manifest/activity-element.html#nohist

If I'm on the wrong track here, perhaps you could describe what you
want step-by-step. At the moment, it sounds like you want the stack to
have just one activity at all times.


Cheers,

Sean


On Fri, Jun 4, 2010 at 9:52 AM, mike <hasitharand...@gmail.com> wrote:
> hi Sean Hodges,
>
> it's working correctly. and is there a way to achieve this thing using
> startActivity()???
>
> Starting Activity B like this
>
> startActivity(intent);
>
> so when i press back button from Activity B i'm doing this
>
>       �...@override
>        public boolean onKeyDown(int keyCode, KeyEvent event) {
>                // TODO Auto-generated method stub
>                if (keyCode == KeyEvent.KEYCODE_BACK) {
>                        finish();
>                        return true;
>                }
>                return false;
>        }
>
> and i don't want to redirect to the Activity A. i just want to send it
> to another activity. is this possible???
>
> regards,
> Mike
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to