I have an application calling a second activity using a list of objects. that return the list of objects, my code is following
Intent returnIntent = new Intent();
Bundle bundle = new Bundle();
bundle.putSerializable("myList", (Serializable) list);
returnIntent.putExtras(bundle);
context.setResult(100, returnIntent);
context.finish();
And I am trying to retrive that list of objects, but I cannt
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == 100) {
Bundle bundel = data.getExtras();
try {
list = (List<Model>) bundel.get("myList");
} catch (Exception ex) {
Log.d("MY ERROR", ex.toString());
}
Toast.makeText(GetXmlFromUrlActivity.this, "You need to enter your name: " + list.size(), Toast.LENGTH_LONG).show();
}
}
Can anyone please help me?
you can use two methods:1. Serializable your List ,your cannot put the list to the intent direct
2. you can use static for the (List as global variable