启动服务调用Application onCreate?

发布于 2024-11-18 07:28:32 字数 77 浏览 11 评论 0原文

如果你提供一个扩展的Application类,那么在创建Service时,即使没有Activity被带到前台,onCreate也会被调用吗?

If you provide an extended Application class, will onCreate be called when a Service is created, even if no Activity is brought to the foreground?

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

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

发布评论

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

评论(1

岁月静好 2024-11-25 07:28:32

Application.onCreate 在实例化包中的任何内容之前调用。

来自文档

应用程序启动时调用
在任何其他应用程序之前开始
对象已被创建。
实施速度应尽可能快
可能(例如使用惰性
状态初始化)自
直接花在这个函数上的时间
影响启动性能
第一项活动、服务或
进程中的接收者。

Application.onCreate is called before anything in your package is instantiated.

From the documentation:

Called when the application is
starting, before any other application
objects have been created.
Implementations should be as quick as
possible (for example using lazy
initialization of state) since the
time spent in this function directly
impacts the performance of starting
the first activity, service, or
receiver in a process.

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