NullPointerException异常的android.app.ActivityThread.handleStopActivity [英] NullPointerException in android.app.ActivityThread.handleStopActivity

查看:2007
本文介绍了NullPointerException异常的android.app.ActivityThread.handleStopActivity的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此​​,有错误,不断想出了在跟踪中涉及到我什么,这里是一个样本跟踪:

So there is bug that keeps coming up with out anything in the trace related to me, here is a sample trace:

java.lang.NullPointerException
at android.app.ActivityThread.handleStopActivity(ActivityThread.java:2484)
at android.app.ActivityThread.access$1800(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:948)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3695)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
at dalvik.system.NativeStart.main(Native Method)

其他的痕迹,只有不同的行号相似:2484,2472,和2476

The other traces are similar with only the line number varying: 2484, 2472, and 2476.

另外的3份报告中提到的设备提:M865华为Ascend II里面应该有2.3就可以了。

Also the 3 reports that mention the device mention: M865 Huawei Ascend II which should have 2.3 on it.

在翻翻源2.1 - 4.1(我的应用程序minSdk的7)在给定的行号,这些都是可能抛出的错误的行:

After looking through the source for 2.1 - 4.1 ( my app minSdk is 7 ) at the given line numbers these are the lines that could have thrown the error:

2.3.7 - 行<一href="http://grep$c$c.com/file/repository.grep$c$c.com/java/ext/com.google.android/android/2.3.7_r1/android/app/ActivityThread.java?av=f#2472">2472

2.3.7 - line 2472

2.3.6 - 行<一href="http://grep$c$c.com/file/repository.grep$c$c.com/java/ext/com.google.android/android/2.3.6_r1/android/app/ActivityThread.java?av=f#2472">2472

2.3.6 - line 2472

private final void handleStopActivity(IBinder token, boolean show, int configChanges) {
    ActivityClientRecord r = mActivities.get(token);
    r.activity.mConfigChangeFlags |= configChanges; // line 2472

    StopInfo info = new StopInfo();
    performStopActivityInner(r, info, show);
    ...

任何想法是什么原因造成这个问题以及如何prevent呢?

Any ideas what is causing this and how to prevent it?

推荐答案

嗯,好像你的任务

 ActivityClientRecord r = mActivities.get(token);

可能会返回一个空值。之后,你将在访问一个空对象

may return a null value. After that you would be accessing a null object in

r.activity.mConfigChangeFlags |= configChanges; // line 2472

因此​​,如果您验证之间通过

So, if you validate in between by

if (r==null) return;

你不会得到错误。

you wouldn't get the error.

这篇关于NullPointerException异常的android.app.ActivityThread.handleStopActivity的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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