Friday, August 12, 2011

[android-developers] Re: How to close an activity A and sub activity B that runs in the background?

Activity B is not running in the background. It's already stopped, so
you just need to call finish() to stop Activity A.

But since you already do that I assume that there is some other
problem. Maybe you call startActivity() to get back to Activity A from
Activity B? Call finish() instead in Activity B.

On 10 Aug, 17:06, xzoom <yoni.se...@gmail.com> wrote:
> Hi,
> I have an activity A (a menu) that creates and start activity B (a
> running game).
>
>         public void onClick(View v) {
>                 switch(v.getId()){
>                         case R.id.start:
>                                 Intent i = new Intent(this, GameActivity.class);
>                                 startActivity(i);
>                                 break;
>                         case R.id.exit:
>                                 finish();
>                                 break;
>                 }
>         }
>
> When I'm back into the menu (activity A) and while activity B is in
> the background , I want to stop activity A and B. How to do it?
> thanks.

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment