Activity 崩溃生命周期方法 - android

Activity crash lifecycle method - android(Activity 崩溃生命周期方法 - 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)