活动崩溃生命周期方法-Android [英] Activity crash lifecycle method - android
本文介绍了活动崩溃生命周期方法-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 非常适合捕获崩溃.
这篇关于活动崩溃生命周期方法-Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文