我試圖將響應對象(soapobject)發送到其他活動。如何在活動之間傳遞對象實例
注意:我沒有創建對象,它是從web服務接收到的響應。
我在第一個活動的邏輯是,如果響應中包含一個或更多的結果,然後將其發送到用於進一步處理的下一個活動(否則顯示「no results
」消息)
MY問題:putExtra
不支持發送non serilaized
或non parcelable object
。
錯誤消息:The method putExtra(String, boolean) in the type Intent is not applicable for the arguments (String, SoapObject)
這裏是我的代碼有什麼建議?
SoapObject soapResponse = soaphttp.fetchNextCatalogueRange(0, numberOfItems);
Intent ResultsActivityIntent = new Intent(MainActivity.this,SearchResultsActivity.class);
// Send data object with the Intent
ResultsActivityIntent.putExtra("ResultObj", soapResponse);
startActivity(ResultsActivityIntent);
http://stackoverflow.com/questions/2736389/how-to-pass-object-from-one-activity-to-another-in-android – user2450263
你應該實現'Parcelable'。看看這個答案[如何在活動之間傳遞對象](http://stackoverflow.com/questions/2736389/how-to-pass-object-from-one-activity-to-another-in-android) – Apoorv
不能使用因爲我沒有創建對象,所以我將它作爲搜索結果接收,而不是可以投射的。 – user1882582