0

I have an application that works correctly. I press the "back" button and close the application, then I open the application and working properly I press the "home" and go to the main screen of the device, then I open the application and working properly

The problem is as follows:

I leave the application using "Back" or "Home" and if I use a task killer and close the process, when I open the application again shows a "Forced close"

I'm using some libraries.

There is some method, such as "low on memory", "OnFinish", etc, to help me handle this error?

Attached the log with error

Thank you very much in advance

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
Sergio76
  • 3,835
  • 16
  • 61
  • 88
  • I'm not sure I'd worry about this- a task killer violently terminates your program without playing nice. Its the equivalent of alt-ctrl-delete on windows. Do you care if you crash when that happens? – Gabe Sechan Feb 26 '13 at 22:23
  • I think it's easier than that? I think it looks like you have a `NullPointerException`: proyect.com.test.Hola.onCreate(Hola.java:222) – kaderud Feb 26 '13 at 22:24
  • `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..java:2108)` – Simon Feb 26 '13 at 22:28
  • You are misunderstanding this. The fact you used a task killer has nothing to do with it. Find the null pointer exception and what causes it and your problem goes away. You can replicate this in developer options by selecting do not keep activities. Your crash would also happen is Android decided to kill your activity. – Simon Feb 26 '13 at 22:31
  • I understand. Is there any way to locate the NullPointerException? I'm using some external libraries and can be hard to find .. – Sergio76 Feb 26 '13 at 22:54
  • 2
    Look for "caused by", then keep looking down for the first line of code referenced from your app. Looks like this `at proyect.com.test.Hola.onCreate(Hola.java:222)` – Simon Feb 26 '13 at 22:58
  • @MiguelC Did you solve your problem? – tsil Apr 24 '13 at 09:44

2 Answers2

1

I found the solution here https://github.com/maurycyw/StaggeredGridView/issues/12.

Just replace this constructors to match this:

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]);
    }
}
tsil
  • 2,069
  • 7
  • 29
  • 43
0

tsil's answer gets at the root, but the link doesn't explain exactly WHY it's happening. Or how to reproduce.

DMart
  • 2,401
  • 1
  • 14
  • 19