有谁能够告诉什么是使用的开始活动的结果安卓 [英] can anybody tell what is use of start activity for result in android

查看:95
本文介绍了有谁能够告诉什么是使用的开始活动的结果安卓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

喜的朋友 有谁能够告诉什么是使用的开始活动的结果在Android的请举个例子,什么是startactivity之间的差异,startactivityforresult?

Hi friends can anybody tell what is use of start activity for result in android please give example and what is difference between startactivity and startactivityforresult?

感谢

推荐答案

startActivityForResult()允许您在启动活动,并得到一些数据备份。试想一下,你有一些文件选择器的活动。就可以开始它,当用户选择文件时,该结果被赋予回原始活性。

startActivityForResult() allows you to start activity and get some data back. Imagine that you have some file picker activity. You can start it and when user chooses the file, the result is given back to the original activity.

另外,也可以使用,如果你只是想确保第二个活动已成功完成出头。

Also, it can be used if you simply want to ensure that the second activity has successfully done somethings.

结果code在onActivityResult方法获得:

The result code is obtained in onActivityResult method:

@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        // Result OK.d.
        if (requestCode == resultCode) {
            // do something good
        }
    }

这篇关于有谁能够告诉什么是使用的开始活动的结果安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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