我正在开发一个应用程序,它在崩溃的情况下需要在崩溃时保存一些数据.现在,我将数据保存在 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!