Android应用程序对象的生命周期 [英] Android Application object life cycle

查看:178
本文介绍了Android应用程序对象的生命周期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找不到应用程序的对象(扩展应用)的生命周期。 举例来说,如果我有通过报警称为广播接收器会发生什么。将应用程序的方法被调用?或者就是一切独立于应用程序? 如果我有一个datahelper实例化的应用程序,我从广播接收器调用它,将它用? 这是应用程序对象的生命周期,当它被摧毁?当使用报警器时,它叫什么名字?当活动是不是在前台的应用程序对象,会发生什么? 提前致谢。吉列尔莫。

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.

推荐答案

看它是这样的:以前一切,有应用程序。它是在你的的BroadcastReceiver ,您的活动之前情况下,你的服务之前情况下,等不要紧,东西是否在前台。当所有的活动的实例都不见了应用程序将被终止,当你从你的的BroadcastReceiver ,一旦你的服务实例被终止。有没有保证,它会被杀死,但这是最后的事情去当操作系统决定你的应用程序必须死。

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.

这篇关于Android应用程序对象的生命周期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆