几个线程=几个应用程序上下文?

发布于 2024-12-23 12:06:34 字数 157 浏览 3 评论 0原文

过去三天一直让我头疼:
我有一个 MyApp 扩展应用程序。 当我从我的服务(在不同线程中运行)调用 getApplication() 时,我得到的 MyApp 实例与我从主线程中运行的 activites 调用 getApplication() 时得到的实例不同。
这是正常行为吗?

it's been giving me headaches for the past 3 days :
I have a MyApp extending Application.
When I call getApplication() from my services (running in different threads), I get a different instance of MyApp than when I call getApplication() from activites running in the main thread.
Is that a normal behavior ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

壹場煙雨 2024-12-30 12:06:34

除非您的服务在不同的进程中运行,否则这种情况不会发生。您确定它们实际上是不同的实例吗?你在什么平台上测试?

Unless your services are running in different processes this shouldn't happen. Are you sure they are actually different instances? On what platform are you testing?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文