0

Assume i has activity A and B and external class C. class C contains code to create dialog but requires contex. class B is like this one

activity A is in focus(active). Activity A call C to create dialog. In first case, A send's it's ActivityContext to C. In second case, C get application activity from B.

Are those two cases leads to same result? E.G dialog will pop up on a screen (on a screen of activity A)

4

1 回答 1

0

是的,在 android 中,每个应用程序只有 1 个“上下文”,文档称为应用程序上下文,几乎每个与您的活动相关的组件都存在于其中,因此您使用的活动上下文引用无关紧要,在end 是相同的,因为所有活动都存在于其中,并且考虑到此应用程序上下文遵循单例设计模式,请确保它是虚拟机中的完全相同的实例对象......

问候!

于 2013-06-04T21:15:54.843 回答