android Fragment re-creation after onDestroy - FragmentManagerState ClassNotFound
Asked Answered
S

0

7

I'm working on an activity with a viewpager with 3 fragments.

After starting a pick image intent onactivityResult is called but
the starter activity is destroyed & created again.

(I've turned on Don't keep any activities,Developer settings.)

Now the problem is after activity is created fragments are also created again (Observed via Log)

This appears in Log after activity recreated.

 E/Parcel: Class not found when unmarshalling: androidx.fragment.app.FragmentManagerState
    java.lang.ClassNotFoundException: androidx.fragment.app.FragmentManagerState

The onActivity result is programatically forwarded to fragment via Activity>getsViewpager>getsAdapter>getsFragment methods.

but now getContext() in fragment returns null. (Which means new fragments are created but onactivityResult passes to old fragment?) What i expect is either the old fragments should be reattached or the onActivityResult passed to new fragments.

How can i distinguish new/old activity/fragments? How can i simply restore fragments after activity recreated? What is the problem causing Class not found when unmarshalling error.

Slr answered 9/1, 2019 at 16:25 Comment(2)
Do you have a solution for this yet?Mcdonough
I didn't solve it but was successful to bypass it by cleaning the code.It was probably the result of messy code. Unfortunately I don't exactly remember what i didSlr

© 2022 - 2024 — McMap. All rights reserved.