我想發送一個 arraylist 到 parent activity
private ArrayList<Receipt> receipts = new ArrayList<Receipt>();
Intent data = new Intent();
data. // what to do here?
setResult(RESULT_OK, data);
//************************************
下面是簡單的代碼
public class Receipt {
public String referenceNo;
public byte[] image;
public String comments;
public Date createdOn;
public Date updatedOn;
如何在 intent 中添加,還有如何從 parent activity 裡檢索?
onActivityResult(final int requestCode, int resultCode, final Intent data)
public class Receipt implements Serializable{
public String referenceNo;
public byte[] image;
public String comments;
public long createdOn;
public long updatedOn;
//...
}
//Put the list in the intent
List<Receipt> list = ...
Intent data = new Intent();
data.putExtra("tag", list);
//Read the list from the intent:
list = (List<Receipt>) data.getSerializableExtra("tag");