Android 是否有等效的 Application::onDestroy() ?
您好,我正在使用 Application::onCreate 来放置应用程序的初始化代码,但是当等待一段时间并启动其他应用程序时,我注意到 Application 类的实例再次创建......
如何全局检测 Android 何时关闭我的应用程序实例?
Hi I am using the Application::onCreate to put my initialisation code of my app, but when waiting some time and starting other apps, I noticed the instance of the Application class gets created again...
How to detect globally when Android is shuttting down my Application instance?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我一直在使用 Service 类,从那以后没有任何问题。如果有人有更好的答案,请告诉我。
I have been using the Service class and had no problem since. If someone has a better answer, let me know.
你不能那样做。用户/环境可以在生产中手动终止应用程序。 Android 不会就此向您提供任何反馈。
PS如果您使用模拟进程环境,您可以查看应用程序
You can't do that. User/Environment can kill the application manually on production. Android would not give you any feedback about this.
P.S. If you're using emulated process environment you can take a look at Application onTerminate method.
我不是一个经验丰富的 Android 开发人员。但作为初学者,我认为你可以使用Activity的onDestroy()方法。
查看活动的生命周期是个好主意。
(在下面的链接中搜索Lifecycle)
http://developer.android.com/guide/topics/fundamentals/activities.html
I am not an experienced android developer. But as a beginner, I think you can use the onDestroy() method of the Activity.
It's a good idea for you to look into the Lifecycle of the Activity.
(Search for Lifecycle in the following link)
http://developer.android.com/guide/topics/fundamentals/activities.html