如何从一个包含类的活动中开始的意图的结果(startActivityForResult) [英] How to Start an Intent for Result from a contained class of an Activity (startActivityForResult)
问题描述
这是一个跟进我的previous问题: <一href="http://stackoverflow.com/questions/6337135/how-to-start-an-intent-from-a-contained-class-of-an-activity">How从包含类的活动中开始的意图
基本上,我意识到,我需要从一个包含类的调用 startActivityForResult
(而不是 startActivity
)活动。从previous问题的答案通过从活动类的背景下所包含的类。然而,仅靠上下文是不够的,叫 StartActivityForResult
。
什么是做到这一点的最好方法是什么?我一定要对整个活动课传递给方法所包含的类?
是的。通过你的活动,以所包含的类作为参数。</ P>
P.S。不要存储参考活动。因为你需要它传递入。
This is a follow up to my previous question: How to Start an Intent from a contained class of an Activity
Basically, I realized that I need to call startActivityForResult
(and not startActivity
) from a contained class of an Activity. The answer from the previous question passed the Context from the Activity class to the contained class. However, the context alone isn't enough to call StartActivityForResult
.
What is the best way to do this? Do I have to pass the entire Activity Class to the method in the contained class?
Yes. Pass your Activity to the contained class as a parameter.
P.S. Do NOT store the reference to the Activity. Pass it in as you need it.
这篇关于如何从一个包含类的活动中开始的意图的结果(startActivityForResult)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!