在uncaughtException()调用时启动活动 [英] starting activity on uncaughtException() call

查看:218
本文介绍了在uncaughtException()调用时启动活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我出现未捕获的异常时,我想从我的 UncaughtExceptionHandler 开始一个新的活动。这是可能的吗?

I want to start a new activity from my UncaughtExceptionHandler when an uncaught exception appears. Is this possible?

我认为当前活动无法在其错误状态下启动新的子活动,因为我总是收到以下错误:

I think the current activity can't start a new child activity in its "error" state because I always get this errors:

07-14 14:34:06.075: INFO/ActivityManager(74): Starting activity: Intent { flg=0x10000000 cmp=de.rwth/system.ErrorHandler (has extras) }
07-14 14:34:06.615: WARN/ActivityManager(74): Activity pause timeout for HistoryRecord{4338f8d8 de.rwth/.main}
07-14 14:34:16.115: WARN/ActivityManager(74): Launch timeout has expired, giving up wake lock!
07-14 14:34:16.628: WARN/ActivityManager(74): Activity idle timeout for HistoryRecord{433a89d8 de.rwth/system.ErrorHandler}

我尝试从一个新线程启动子活动,因为我认为当前线程可能处于不允许开始新活动的状态,但这没有也不工作

I tried to start the child activity from a new thread, because i thought the current thread might be in a state where it is not allowed to start a new activity but this didn't work too.

有没有人知道这可以如何工作?
在这种错误状态下,如何防止当前活动阻止所有内容?是否有任何方式设置异常处理?

So does anyone know how this could work? How do i prevent the current activity from blocking everything while in this error state? is the any way to set the exception to handled?

推荐答案

您将需要做的是指定您的异常显示 Activity 在您的清单文件中,并设置 android:taskAffinity android:process 与您的主要流程不同。然后,您需要指定意图过滤器并使用它来启动活动并传递数据。

What you will need to do is specify your exception display Activity in your manifest file and set android:taskAffinity and android:process to values different from your main process. Then you'll need to specify an intent filter and use that to start the activity and pass the data.

默认情况下,taskAffinity从主< application> 标签中处理,与< manifest> 标签。你可能想要像 android:taskAffinity =org.example.package.TASK.ExceptionDisplay

By default the taskAffinity is inheried from the main <application> tag and is the same page name set in the <manifest> tag. You probably want something like android:taskAffinity="org.example.package.TASK.ExceptionDisplay"

默认情况下一个< application> 标签中的所有内容都在相同的过程中运行。您可以使用 android:process 属性更改,您可能希望像 android:process =:exception_process

By default everything in one <application> tag runs in the same process. You can change that using the android:process attribute you probably want something like android:process=":exception_process".

查看这个文档了解更多详情。

Check out this documentation for more details.

这篇关于在uncaughtException()调用时启动活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆