本文介紹了Activity 崩潰生命周期方法 - android的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
限時送ChatGPT賬號..
我正在開發一個應用程序,它在崩潰的情況下需要在崩潰時保存一些數據.現在,我將數據保存在 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的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!