[問題]在onSaveInstanceState(), Bundle HashMap
想請問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
02/19 19:54, 1F
→
02/19 21:30, , 2F
02/19 21:30, 2F
→
02/19 21:30, , 3F
02/19 21:30, 3F
→
02/19 21:32, , 4F
02/19 21:32, 4F
→
02/19 22:15, , 5F
02/19 22:15, 5F
AndroidDev 近期熱門文章
PTT數位生活區 即時熱門文章