0

我有一个可以正常工作的应用程序。我按“返回”按钮并关闭应用程序,然后打开应用程序并正常工作按“主页”并转到设备的主屏幕,然后打开应用程序并正常工作

问题如下:

我使用“返回”或“主页”离开应用程序,如果我使用任务杀手并关闭进程,当我再次打开应用程序时会显示“强制关闭”

我正在使用一些库。

有一些方法,例如“内存不足”、“OnFinish”等,可以帮助我处理这个错误吗?

附上错误日志

非常感谢您提前

02-26 23:11:48.022: E/AndroidRuntime(13427): FATAL EXCEPTION: main
02-26 23:11:48.022: E/AndroidRuntime(13427): java.lang.RuntimeException: Unable to start activity ComponentInfo{proyect.com.test/proyect.com.test.Hola}: java.lang.NullPointerException
02-26 23:11:48.022: E/AndroidRuntime(13427):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
02-26 23:11:48.022: E/AndroidRuntime(13427):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
02-26 23:11:48.022: E/AndroidRuntime(13427):    at android.app.ActivityThread.access$600(ActivityThread.java:141)
02-26 23:11:48.022: E/AndroidRuntime(13427):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
02-26 23:11:48.022: E/AndroidRuntime(13427):    at android.os.Handler.dispatchMessage(Handler.java:99)
02-26 23:11:48.022: E/AndroidRuntime(13427):    at android.os.Looper.loop(Looper.java:137)
02-26 23:11:48.022: E/AndroidRuntime(13427):    at android.app.ActivityThread.main(ActivityThread.java:5041)
02-26 23:11:48.022: E/AndroidRuntime(13427):    at java.lang.reflect.Method.invokeNative(Native Method)
02-26 23:11:48.022: E/AndroidRuntime(13427):    at java.lang.reflect.Method.invoke(Method.java:511)
02-26 23:11:48.022: E/AndroidRuntime(13427):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
02-26 23:11:48.022: E/AndroidRuntime(13427):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
02-26 23:11:48.022: E/AndroidRuntime(13427):    at dalvik.system.NativeStart.main(Native Method)
02-26 23:11:48.022: E/AndroidRuntime(13427): Caused by: java.lang.NullPointerException
02-26 23:11:48.022: E/AndroidRuntime(13427):    at android.os.Parcel.readIntArray(Parcel.java:784)
02-26 23:11:48.022: E/AndroidRuntime(13427):    at com.origamilabs.library.views.StaggeredGridView$SavedState.<init>(StaggeredGridView.java:2108)
02-26 23:11:48.022: E/AndroidRuntime(13427):    at com.origamilabs.library.views.StaggeredGridView$SavedState.<init>(StaggeredGridView.java:2104)
02-26 23:11:48.022: E/AndroidRuntime(13427):    at com.origamilabs.library.views.StaggeredGridView$SavedState$1.createFromParcel(StaggeredGridView.java:2132)
02-26 23:11:48.022: E/AndroidRuntime(13427):    at com.origamilabs.library.views.StaggeredGridView$SavedState$1.createFromParcel(StaggeredGridView.java:1)
02-26 23:11:48.022: E/AndroidRuntime(13427):    at android.os.Parcel.readParcelable(Parcel.java:2103)
02-26 23:11:48.022: E/AndroidRuntime(13427):    at android.os.Parcel.readValue(Parcel.java:1965)
02-26 23:11:48.022: E/AndroidRuntime(13427):    at android.os.Parcel.readSparseArrayInternal(Parcel.java:2255)
02-26 23:11:48.022: E/AndroidRuntime(13427):    at android.os.Parcel.readSparseArray(Parcel.java:1687)
02-26 23:11:48.022: E/AndroidRuntime(13427):    at android.os.Parcel.readValue(Parcel.java:2022)
02-26 23:11:48.022: E/AndroidRuntime(13427):    at android.os.Parcel.readMapInternal(Parcel.java:2226)
02-26 23:11:48.022: E/AndroidRuntime(13427):    at android.os.Bundle.unparcel(Bundle.java:223)
02-26 23:11:48.022: E/AndroidRuntime(13427):    at android.os.Bundle.getSparseParcelableArray(Bundle.java:1240)
02-26 23:11:48.022: E/AndroidRuntime(13427):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:845)
02-26 23:11:48.022: E/AndroidRuntime(13427):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1088)
02-26 23:11:48.022: E/AndroidRuntime(13427):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1070)
02-26 23:11:48.022: E/AndroidRuntime(13427):    at android.support.v4.app.FragmentManagerImpl.dispatchCreate(FragmentManager.java:1856)
02-26 23:11:48.022: E/AndroidRuntime(13427):    at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:210)
02-26 23:11:48.022: E/AndroidRuntime(13427):    at proyect.com.test.Hola.onCreate(Hola.java:222)
02-26 23:11:48.022: E/AndroidRuntime(13427):    at android.app.Activity.performCreate(Activity.java:5104)
02-26 23:11:48.022: E/AndroidRuntime(13427):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
02-26 23:11:48.022: E/AndroidRuntime(13427):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
02-26 23:11:48.022: E/AndroidRuntime(13427):    ... 11 more
4

2 回答 2

1

我在这里找到了解决方案https://github.com/maurycyw/StaggeredGridView/issues/12

只需替换此构造函数以匹配此:

private SavedState(Parcel in) {
    super(in);
    firstId = in.readLong();
    position = in.readInt();
    topOffsets = in.createIntArray();
    mapping = new ArrayList<ColMap>();
    in.readTypedList(mapping, ColMap.CREATOR);
}

private ColMap(Parcel in) {
    tempMap = in.createIntArray();
    values = new ArrayList<Integer>();
    for (int index = 0; index < tempMap.length; index++) {
        values.add(tempMap[index]);
    }
}
于 2013-04-24T10:20:27.043 回答
0

tsil 的答案从根本上说,但该链接并没有准确解释为什么会发生这种情况。或者如何重现。

于 2014-11-26T15:55:50.007 回答