简体   繁体   English

防止android在崩溃后重新创建活动堆栈

[英]Prevent android from recreating activity stack after crash

I have an application that is encountering an exception in an activity a few levels down the stack. 我有一个应用程序在堆栈中的几个级别的活动中遇到异常。 I am also using ACRA for crash reporting in status bar notifications + dialog mode. 我还在状态栏通知+对话框模式中使用ACRA进行崩溃报告。 What I see happening is that when my process is killed because of the exception, Android recreates the activity stack upto the offending activity's parent. 我看到的情况是,当我的进程因异常而被杀死时,Android会将活动堆栈重新创建到违规活动的父级。 I would like to override this behavior. 我想覆盖这种行为。 If my app crashed, I would like it to remain crashed. 如果我的应用程序崩溃了,我希望它仍然崩溃。

There is discussion on this in android-developers: android-developers中有关于此的讨论:

http://groups.google.com/group/android-developers/browse_thread/thread/b274cfa64b17f535/92d8da160be85748?lnk=gst&q=force+close+restarts#92d8da160be85748 http://groups.google.com/group/android-developers/browse_thread/thread/b274cfa64b17f535/92d8da160be85748?lnk=gst&q=force+close+restarts#92d8da160be85748

I have also read through the discussion in this stack overflow thread: Prevent Activity Stack from being Restored? 我还阅读了此堆栈溢出线程中的讨论: 阻止活动堆栈被还原?

but am looking to see if there is an update in the platform for this or a newer technique. 但我正在寻找平台上是否有更新此技术或更新技术。 Right now the restart behavior is causing issues with ACRA as the crash report notification is cleared as soon as the activity stack is recreated, leaving the user no time to send the report. 现在,重新启动行为导致ACRA出现问题,因为一旦重新创建活动堆栈就会清除崩溃报告通知,从而使用户没有时间发送报告。

I use ACRA also, and I found that adding forceCloseDialogAfterToast=true to the @ReportCrashes annotation will suppress the restart. 我也使用ACRA,我发现在@ReportCrashes注释中添加forceCloseDialogAfterToast = true将禁止重启。 The cost, however, is that you get the Android Force Close dialog. 然而,成本是您获得Android Force Close对话框。 I cannot figure out how to get rid of that AND prevent the app restart... 我无法弄清楚如何摆脱它并阻止应用程序重启...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM