我需要發送一個自定義對象和一個字符串到其他活動。自定義對象(User)實現了Parcelable接口。 我這樣做:發送自定義對象和一個字符串到其他活動
Intent intent = new Intent("action") ;
Bundle data = new Bundle() ;
data.putString("EDIT", "EDIT");
data.putParcelable("DATA", user) ; //user is custom object
intent.putExtra("BUNDLE", data) ;
startActivity(intent) ;
在其他活動中,我收到的意圖,但編輯的地圖數據爲空,只有在意圖Pacelable數據,編輯字符串錯過。
Intent intent = getIntent() ;
String edit = bundle.getString("EDIT") ; // edit = null should be EDIT
Bundle bundle =intent.getBundleExtra("BUNDLE") ;
任何其他開發人員都知道這個問題,你能給我一些建議嗎?謝謝。
看到更新的答案 – 2013-04-27 03:53:53