Just tested it, and yes finishActivity only works in the activity which starts another.
Here's what I did to resolve my problem,
Activity B uses startActivityForResult(intentC, 100) to start activity C, and overrides onActivityResult(...) to catch the result from acitvity C, finish() B itself when gets the exact requestCode and resultCode from activity C.
Bob
On Thu, Nov 5, 2009 at 6:51 PM, Dianne Hackborn <hackbod@android.com> wrote:
Your first comment was correct -- finishActivity lets B finish C if B was the one that used startActivityForResult() to start C. The requestCode has no meaning outside the context of B.--
On Thu, Nov 5, 2009 at 3:04 PM, PJ <pjbarnes@gmail.com> wrote:
Hmm, I went back and read the Javadoc for finishActivity(), and it's
not clear whether activities should be allowed to use finishActivity()
for activities that it didn't start. I can interpret it both ways.
So, you may be right; maybe it should work.
But at the very least, maybe you could try the different approach
above. /shrug
I hope you let us know how it turns out, because I've only used finish
(), and not finishActivity().
> accomplish:http://groups.google.com/group/android-developers/browse_thread/threa...
On Nov 5, 4:54 pm, PJ <pjbar...@gmail.com> wrote:
> Check out this discussion, it sounds similar to what you want to
>
> Specifically, check out FLAG_ACTIVITY_CLEAR_TOP at:http://developer.android.com/reference/android/content/Intent.html#FL...
>> > - Show quoted text -- Hide quoted text -
> Hope this helps!
> -- PJ
>
> On Nov 5, 4:48 pm, PJ <pjbar...@gmail.com> wrote:
>
>
>
> > finishActivity() is intended to be used to force-finish an activity,
> > *** from the same activity that started it ***.
> > So, if you want to force-finish Activity B, then I think Main Activity
> > is the only one that can do it via finishActivity(), because Main
> > Activity is the one that started it.
>
> > However, I think there's a way for Activity C to terminate and to go
> > back directly to Main Activity and to ask Main Activity to destroy all
> > activities "above" it (B). Let me see if I can find that...
>
> > -- PJ
>
> > On Nov 5, 2:58 pm, Bob Cai <caibo...@gmail.com> wrote:
>
> > > Hello,
>
> > > In main Activity, I called startActivityForResult(intentB, 100) to start a
> > > new activity B, then in B, I called startActivity(intentC) to start another
> > > activity C. Lastly I wanted to call finishActivity(100) in C to close
> > > activity B, but seemed it was not successfully destoried(I can use BACK key
> > > to see it's still there.).
>
> > > Anyone can give advice of this?
>
> > > Thanks,
> > > Bob- Hide quoted text -
>
>
> - Show quoted text -
--
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
Dianne Hackborn
Android framework engineer
hackbod@android.com
Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them.
--
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
--
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