Android的 - 返回到调用活动 [英] Android - Return to calling Activity
问题描述
新手的问题,从iPhone开发人员。
Newbie Question from an iPhone developer.
我称之为startActivity(意向)和新活动的负荷。我该如何去'回'到一旦按下按钮呼叫活动。 啪的活动从堆栈基本相符。
I have called the startActivity(intent) and the new activity loads. How do I go 'back' to the calling activity once a button is pushed. 'Popping' the activity off the stack basically.
推荐答案
如果您已经创建了新的活动与<一个href="http://developer.android.com/reference/android/content/Context.html#startActivity%28android.content.Intent%29"><$c$c>startActivity$c$c>你只需要调用<一个href="http://developer.android.com/reference/android/app/Activity.html#setResult%28int,%20android.content.Intent%29"><$c$c>finish$c$c>.如果您已经通过调用<衍生的新活动href="http://developer.android.com/reference/android/app/Activity.html#startActivityForResult%28android.content.Intent,%20int%29"><$c$c>startActivityForResults$c$c>那么你就需要调用<一个href="http://developer.android.com/reference/android/app/Activity.html#setResult%28int,%20android.content.Intent%29"><$c$c>setResult$c$c>然后<一href="http://developer.android.com/reference/android/app/Activity.html#finish%28%29"><$c$c>finish$c$c>为了通过回数据到<一href="http://developer.android.com/reference/android/app/Activity.html#onActivityResult%28int,%20int,%20android.content.Intent%29"><$c$c>onActivityResult$c$c>先前活动的方法。
If you had created the new Activity with startActivity
you just need to call finish
. If you had spawned the new Activity by calling startActivityForResults
then you need to call setResult
and then finish
in order to pass back data to the onActivityResult
method of the prior Activity.
这篇关于Android的 - 返回到调用活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!