Android的 - 返回到调用活动 [英] Android - Return to calling Activity

查看:103
本文介绍了Android的 - 返回到调用活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

新手的问题,从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你只需要调用<一个href="http://developer.android.com/reference/android/app/Activity.html#setResult%28int,%20android.content.Intent%29"><$c$c>finish.如果您已经通过调用<衍生的新活动href="http://developer.android.com/reference/android/app/Activity.html#startActivityForResult%28android.content.Intent,%20int%29"><$c$c>startActivityForResults那么你就需要调用<一个href="http://developer.android.com/reference/android/app/Activity.html#setResult%28int,%20android.content.Intent%29"><$c$c>setResult然后<一href="http://developer.android.com/reference/android/app/Activity.html#finish%28%29"><$c$c>finish为了通过回数据到<一href="http://developer.android.com/reference/android/app/Activity.html#onActivityResult%28int,%20int,%20android.content.Intent%29"><$c$c>onActivityResult先前活动的方法。

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆