您的位置:首页 > 编程语言 > Python开发

python bottle框架(WEB开发、运维开发)教程

2015-05-26 14:32 701 查看
摘自帮助文档:

Sometimes you want to get a result back from an activity when it ends. For example, you may start an activity that lets the user pick a person in a list of contacts; when it ends, it returns the person that was selected. To do this, you call the
startActivityForResult(Intent,  int)
version with a second integer parameter identifying the call. The result will come back through your
onActivityResult(int,  int, Intent)
method.

When an activity exits, it can call
setResult(int)
to return data back to its parent. It must always supply a result code, which can be the standard results RESULT_CANCELED, RESULT_OK, or any custom values starting at RESULT_FIRST_USER. In addition, it can optionally return back an Intent containing any additional data it wants. All of this information appears back on the parent's
Activity.onActivityResult()
, along with the integer identifier it originally supplied

1 需要从Activity2 向Activity1回调并传参时使用
startActivityForResult(Intent, int)


public void startActivityForResult (Intent intent, int requestCode)

Intent intent:系统会根据这个确定目的Activity

int requestCode:用于标识该Intent 回来后确定是不是想要的返回

2 其返回的数据能在重写的onActivityResult中获取。

3 在Activity2中调用setResult(int)来返回数据。

综上,当需要从Activity2返回Activity1时需要以上三个地方的配合。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: