Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crashes when app goes to background #2

Open
pouriabagheri opened this issue Mar 15, 2018 · 1 comment
Open

Crashes when app goes to background #2

pouriabagheri opened this issue Mar 15, 2018 · 1 comment

Comments

@pouriabagheri
Copy link

pouriabagheri commented Mar 15, 2018

@Scrounger the app crashes when it goes to background by pressing home button.
seems to be an issue due to serialization
Here is the log:

E/AndroidRuntime: FATAL EXCEPTION: main Process: com.scrounger.countrycurrencypicker.sample, PID: 9449 java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.scrounger.countrycurrencypicker.library.Buttons.CountryCurrencyButton) at android.os.Parcel.writeSerializable(Parcel.java:1761) at android.os.Parcel.writeValue(Parcel.java:1709) at android.os.Parcel.writeArrayMapInternal(Parcel.java:777) at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1506) at android.os.Bundle.writeToParcel(Bundle.java:1181) at android.os.Parcel.writeBundle(Parcel.java:817) at android.support.v4.app.FragmentState.writeToParcel(Fragment.java:148) at android.os.Parcel.writeTypedArray(Parcel.java:1401) at android.support.v4.app.FragmentManagerState.writeToParcel(FragmentManager.java:571) at android.os.Parcel.writeParcelable(Parcel.java:1730) at android.os.Parcel.writeValue(Parcel.java:1636) at android.os.Parcel.writeArrayMapInternal(Parcel.java:777) at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1506) at android.os.Bundle.writeToParcel(Bundle.java:1181) at android.app.IActivityManager$Stub$Proxy.activityStopped(IActivityManager.java:4617) at android.app.ActivityThread$StopInfo.run(ActivityThread.java:4012) at android.os.Handler.handleCallback(Handler.java:789) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:172) at android.app.ActivityThread.main(ActivityThread.java:6637) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) Caused by: java.io.NotSerializableException: com.scrounger.countrycurrencypicker.library.Country at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1233) at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1597) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1558) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1481) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1227) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347) at android.os.Parcel.writeSerializable(Parcel.java:1756) at android.os.Parcel.writeValue(Parcel.java:1709)  at android.os.Parcel.writeArrayMapInternal(Parcel.java:777)  at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1506)  at android.os.Bundle.writeToParcel(Bundle.java:1181)  at android.os.Parcel.writeBundle(Parcel.java:817)  at android.support.v4.app.FragmentState.writeToParcel(Fragment.java:148)  at android.os.Parcel.writeTypedArray(Parcel.java:1401)  at android.support.v4.app.FragmentManagerState.writeToParcel(FragmentManager.java:571)  at android.os.Parcel.writeParcelable(Parcel.java:1730)  at android.os.Parcel.writeValue(Parcel.java:1636)  at android.os.Parcel.writeArrayMapInternal(Parcel.java:777)  at android.os.BaseBundle.writeToParcelInner(BaseBundle.java:1506)  at android.os.Bundle.writeToParcel(Bundle.java:1181)  at android.app.IActivityManager$Stub$Proxy.activityStopped(IActivityManager.java:4617)  at android.app.ActivityThread$StopInfo.run(ActivityThread.java:4012)  at android.os.Handler.handleCallback(Handler.java:789)  at android.os.Handler.dispatchMessage(Handler.java:98)  at android.os.Looper.loop(Looper.java:172)  at android.app.ActivityThread.main(ActivityThread.java:6637)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) 

@pouriabagheri
Copy link
Author

For those who face this issue, the cause is serializing listener. so when state loss occurs serialization recreates the listener object ( using the values in the object not the reference ) so the new listener is just a copy of the listener object. the solution is to remove the serialization from listener and create the listeners directly and calling them through the picker object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant