KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I need a little help to solve the following question. I have two activities, A and B. The activity A start B for result, and B sends back to A a serializable object. Activity a starting activity B: ... Intent intent = new Intent(MainActivity.this, ExpenseActivity.class); startActivityForResult(intent, EXPENSE_RESULT); ... Activity B sending data to A: ... ExpensePacket packet = new ExpensePacket(); ... Intent returnIntent = new Intent(); returnIntent.putExtra(MainActivity.PACKET_INTENT,packet); setResult(RESULT_OK,returnIntent); finish(); Point where the activity A gets the data sent from B: protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == EXPENSE_RESULT) { if(resultCode == RESULT_OK){ ExpensePacket result = (ExpensePacket)getIntent().getSerializableExtra(PACKET_INTENT); wallet.Add(result); PopulateList(); } else{ //Write your code otherwise } } } My Serializable object, the one who is sent from B to A: class ExpensePacket implements Serializable { private static final long serialVersionUID = 1L; private Calendar calendar; public void SetCalendar(Calendar aCalendar){ calendar = aCalendar; } public Calendar GetCalendar(){ return calendar; } public String GetMonthYear() { SimpleDateFormat sdf = new SimpleDateFormat("yyyy"); sdf.format(calendar.getTime()); String returnString = ""; returnString += sdf.toString(); returnString += "/"; returnString += Functions.GetMonthName(calendar); return sdf.toString(); } } Somebody can help me to figure out why the data sent from B t
Tags (comma-separated)
Save Edits
Cancel