一个的onActivityResult活动片段startActivityForResult以后不叫 [英] onActivityResult of an Activity not called after startActivityForResult of Fragment

查看:162
本文介绍了一个的onActivityResult活动片段startActivityForResult以后不叫的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个活动的 ActivityOne ActivityTwo 每一个包含一个片段

I have two activities ActivityOne and ActivityTwo each one contains one Fragment

我做了 startActivityForResult(mIntent,REQUEST_ code)从第一个活动的片段( ActivityOne )调用的第二个活动( ActivityTwo ),问题是的onActivityResult 的第二个活动一直没有被调用?

i did startActivityForResult(mIntent, Request_code) from the fragment of the first activity (ActivityOne) for calling the second activity (ActivityTwo), the problem is onActivityResult of the second activity has not being called?

推荐答案

由于在评论中提及,的onActivityResult 将只在活动称为(如 ActivityOne ),它开始有些其他活动(比如 ActivityTwo )的结果是,使用 startActivityForResult(...);

As mentioned in the comment, onActivityResult will only be called in the activity (e.g. ActivityOne) that started some other activity (e.g. ActivityTwo) for a result, using startActivityForResult(...);

您可以在开发者指南在这读了这里

如果,万一,你尝试从 ActivityOne 的东西传递给 ActivityTwo ,结果
你可以使用<一个href=\"http://developer.android.com/reference/android/content/Intent.html#putExtra(java.lang.String,%20double[])\"相对=nofollow> putExtra(...)在 ActivityOne &安培;使用<一个href=\"http://developer.android.com/reference/android/content/Intent.html#getStringExtra(java.lang.String)\"相对=nofollow> getExtra(...)在 ActivityTwo

If, by any chance, you are trying to pass something from ActivityOne to ActivityTwo,
you can use putExtra(...) in ActivityOne & use getExtra(...) in ActivityTwo.

这篇关于一个的onActivityResult活动片段startActivityForResult以后不叫的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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