碰到这种问题还是比较诡异的,这个bug说的是解析实体的问题
报错代码:
但是实际报错的时候是data.getIntExtra(“key”, -1);
只要涉及到Intent的传输数据都会报这个问题
报错原因:
导致报错的原因可能是因为我的窗体嵌套太多,又或者是同时使用eventbus和fragment的回传、activity的回传引起的。
最终就是类似实现的是Parcelable接口,在B应用中序列化实现的是Serializable
解决方式:
在取数据之前,使用
bundle.setClassLoader(getClass().getClassLoader());
即可
android.os.BadParcelableException: ClassNotFoundException when unmarshalling: com.zhongjh.entity.DiaryMain
at android.os.Parcel.readParcelableCreator(Parcel.java:2535)
at android.os.Parcel.readParcelable(Parcel.java:2461)
at android.os.Parcel.readValue(Parcel.java:2364)
at android.os.Parcel.readArrayMapInternal(Parcel.java:2717)
at android.os.BaseBundle.unparcel(BaseBundle.java:271)
at android.os.BaseBundle.containsKey(BaseBundle.java:352)
at android.content.Intent.hasExtra(Intent.java:6033)
at com.zhongjh.phone.ui.indexDiary.IndexDiaryActivity.getPosition(IndexDiaryActivity.java:120)
at com.zhongjh.phone.ui.photo.PhotoFragment.onActivityReenter(PhotoFragment.java:217)
at com.lib.library.phone.base.MySupportActivity.onActivityReenter(MySupportActivity.java:42)
at android.app.ActivityTransitionState.setEnterActivityOptions(ActivityTransitionState.java:169)
at android.app.Activity.onNewActivityOptions(Activity.java:6230)
at android.app.ActivityThread.onNewActivityOptions(ActivityThread.java:2945)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1749)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6321)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:880)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
网友评论