java.lang.RuntimeException:无法使用java.lang.IllegalArgumentException恢复活动 [英] java.lang.RuntimeException: Unable to resume activity with java.lang.IllegalArgumentException

查看:463
本文介绍了java.lang.RuntimeException:无法使用java.lang.IllegalArgumentException恢复活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,当MainActivity调用onResume()时,我有时会遇到此异常。

Recently I sometimes got this exception when MainActivity called onResume().

java.lang.RuntimeException: Unable to resume activity {com.qau4d.c35s3.androidapp/com.xxx.XXX.XXX.MainActivity}: java.lang.IllegalArgumentException
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3400)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3440)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1510)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: java.lang.IllegalArgumentException
at android.os.Parcel.readException(Parcel.java:1687)
at android.os.Parcel.readException(Parcel.java:1636)
at android.app.ActivityManagerProxy.isTopOfTask(ActivityManagerNative.java:5475)
at android.app.Activity.isTopOfTask(Activity.java:5961)
at android.app.Activity.onResume(Activity.java:1252)
at com.qau4d.c35s3.androidapp.onResume(XActivity.java:29)
at com.qau4d.c35s3.androidapp.onResume(MainActivity.java:196)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1269)
at android.app.Activity.performResume(Activity.java:6768)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3377)

两者在 MainActivity 和超类 XActivity 中,只有 super.onResume(); 。经过长时间的正常开发后得到这个异常真的很奇怪。我查了一些相关的参考资料但没有得到。

Both in MainActivity and super class XActivity, only super.onResume(); . It's really strange to get this exception after a long time normal development.I checked some relative reference material but nothing got.

推荐答案

那里你的问题中的信息不足以确定 java.lang.IllegalArgumentException 的原因,不幸的是android ActivityThread doesn' t记录该异常的堆栈跟踪,异常消息显示为空。

There is insufficient information in your question to determine the cause of the java.lang.IllegalArgumentException, Unfortunately the android ActivityThread doesn't log the stacktrace of that exception, and the exception message appears to be empty.

然而,看起来有一种前进的方法。该异常由 ActivityThread :: performResumeActivity 方法中的以下代码处理:

However, it looks like there is a way forward. The exception is handled by the following code in the ActivityThread::performResumeActivity method:

        } catch (Exception e) {
            if (!mInstrumentation.onException(r.activity, e)) {
                throw new RuntimeException(
                    "Unable to resume activity "
                    + r.intent.getComponent().toShortString()
                    + ": " + e.toString(), e);
            }
        }

如果您注册工具您的活动的类,应该可以使用 onException 方法来记录因果异常的堆栈跟踪。另一种可能性是使用 Thread.setUncaughtExceptionHandler 为抛出 IllegalArgumentException 的线程设置处理程序。

If you register an Instrumentation class for your activity, it should be possible to use an onException method to log the stacktrace for the causal exception. Another possibility is to use Thread.setUncaughtExceptionHandler to set a handler for the thread in which the IllegalArgumentException is thrown.

这些不会解决问题(!),但它会让您更接近解决方案。

These won't solve the problem (!) but it will get you a step closer to a solution.

这篇关于java.lang.RuntimeException:无法使用java.lang.IllegalArgumentException恢复活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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