Android应用程序对象的生命周期

发布于 2024-11-05 07:13:42 字数 230 浏览 3 评论 0原文

我找不到Application的对象(延长Application)生命周期。 例如,如果我有一个通过 Alarm 调用的广播接收器,会发生什么情况。会调用应用程序中的方法吗?或者一切都独立于应用程序? 如果我在应用程序中实例化了一个 datahelper 并且我从广播接收器调用它,它是否可用? 当应用程序对象被销毁时,它的生命周期是哪个?使用闹钟时什么时候调用它?当 Activity 不在应用程序对象的前台时会发生什么? 提前致谢。吉列尔莫.

I can't find the Application's object (extend Application) life cycle.
For example, what happens if I have a broadcast receiver which is called through Alarm. Will methods in Application being called? Or is everything independent from the Application?
If I have a datahelper instantiated in the Application and I call it from broadcast receiver, will it available?
Which is the Application object life cycle, when it is destroyed? when is it called when using Alarms? What happens when the activity is not in foreground with the Application object?
Thanks in advance. Guillermo.

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

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

发布评论

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

评论(1

心凉 2024-11-12 07:13:42

这样看:在其他一切之前,有应用程序。它是在您的 BroadcastReceiver 之前、您的 Activity 实例之前、您的 Service 实例之前创建的。前景。当您的所有 Activity 实例消失、您不再使用 BroadcastReceiver 以及您的 Service 实例终止时,应用程序将终止。不能保证它会被杀死,但当操作系统决定您的应用程序必须终止时,这是最后一件事。

Look at it this way: before everything else, there is Application. It is created before your BroadcastReceiver, before your Activity instances, before your Service instances, etc. It doesn't matter whether anything is in the foreground. The application will be terminated when all of your Activity instances are gone, when you're out of your BroadcastReceiver and once your Service instances are terminated. There's no guarantee that it will be killed, but it is the last thing to go when the OS decided that your app must die.

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