简体   繁体   中英

App Crash while parsing data from one fragment to another android

碰撞 数据 检索数据

I don't know what happened in this code. Anyone help me? Thanks in advance.

I am trying to parce data from one fragment to another fragment using parcelable, but my app crashed while fetching.

It's saying that you are calling your hashcode method on a null object which is - GetShopsResponse.Data.Shop.Attachment you should nullcheck it first like this:

GetShopsResponse.Data.Shop.Attachment?.hascode()

I think you passed some data in next fragment (B), then you perform some operation in fragment (B), so if the data is null application was crashed. so check your next fragment (B) and maintain null check condition. if already maintained then you can share code where you fetching data in next fragment.

EDITED:-

if (arguments != null) {
        data = requireArguments().getParcelable<GetShopsResponse.Data.Shop::class.java>("shopData")
    }

note:- check every data with null check, if any data is null then app will crash.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM