[問題]在onSaveInstanceState(), Bundle HashMap

看板AndroidDev作者 (阿銘)時間12年前 (2014/02/19 12:56), 編輯推噓0(005)
留言5則, 2人參與, 最新討論串1/1
想請問Bundle HashMap 發生了錯誤, Logcat 的訊息是 android.os.BadParcelableException: ClassNotFoundException when unmarshalling: com.myapp.model.StationHashMap unmarshalling 時找不到Class = =" 在 com.myapp.model.StationHashMap 有implements Parcelable 而HashMap value 的類別是自訂的類別為Station 程式碼: MapFragment.java: https://gist.github.com/ymhuang0808/9086234 片段程式, 是onSaveInstanceState() 的部分, 主要是將mStationMap set到 stationHashMap 中再put 到bundle 以下都是資料儲存的model 類別都有實做Parcelable StationHashMap.java : https://gist.github.com/ymhuang0808/9086124 Station.java : https://gist.github.com/ymhuang0808/9086148 會寫成StationHashMap 是參考StackOverflow 的這篇http://goo.gl/ZSBlrL 他說Parcelable 比Serializable 快, 也看到有人測試的文章http://goo.gl/Is0eg8 嘗試過的有加入bundle.setClassLoader(getClass().getClassLoader()) 指定ClassLoader 還是沒work... 如果有經驗的大大可以提供一下解決方式,或者提醒能解決的方向 感謝! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 1.168.239.157 ※ 編輯: amhuang 來自: 1.168.239.157 (02/19 12:57) ※ 編輯: amhuang 來自: 1.168.239.157 (02/19 12:57)

02/19 19:54, , 1F
會不會是class沒有在manifest註冊啊
02/19 19:54, 1F

02/19 21:30, , 2F
我從Service bundle 過來就可以... 在SupportMapFragment
02/19 21:30, 2F

02/19 21:30, , 3F
就會不行...
02/19 21:30, 3F

02/19 21:32, , 4F
是Service bundle 到Activity
02/19 21:32, 4F

02/19 22:15, , 5F
只好利用Activity 存了... 然後有restore再call fragment
02/19 22:15, 5F
文章代碼(AID): #1J13b_8K (AndroidDev)
文章代碼(AID): #1J13b_8K (AndroidDev)