Activity crash lifecycle method - android(Activity 崩溃生命周期方法 - android)
问题描述
我正在开发一个应用程序,它在崩溃的情况下需要在崩溃时保存一些数据.现在,我将数据保存在 onDestroy() 中,如下所示:
I'm developing an app which in a case of crash, needs to save some data with the time of the crash. Now, I'm saving the data in onDestroy() like this:
@Override
protected void onDestroy() {
saveState();
super.onDestroy();
}
但每当我故意让我的应用程序崩溃时,不会调用 onDestroy() 并且不会保存我的数据.
But whenever I crash my app on purpose, onDestroy() is not called and my data is not saved.
我的问题是,如何在崩溃时保存我的数据?我应该采取哪种方法?因为我还需要保存崩溃的时间,所以这是强制性的.
My question is, how can I save my data on a crash? Which approach should I take? Because I need the time of the crash to be also saved, it's mandatory.
推荐答案
UncaughtExceptionHandler 非常适合捕获崩溃.
这篇关于Activity 崩溃生命周期方法 - android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Activity 崩溃生命周期方法 - android
基础教程推荐
- RabbitMQ:消息保持“未确认"; 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
