Skip to content
Advertisement

AndroidStudio: java. How can i return an arraylist to main activity?

I tried this way:
The application stops working on setResult only when the arraylist is not empty.
SECONDARY ACTIVITY

Intent d = new Intent();
d.putExtra("cat",(Serializable)  category.categories);
setResult(RESULT_OK, d);
finish();

CATEGORIES INITIALIZATION:

public ArrayList<buy_categories2> categorie= new ArrayList<buy_categories2>();

MAIN ACTIVITY in the method onActivityResult:

ArrayList<buy_categories2> b2 = new ArrayList<buy_categories2>();
b2 = (ArrayList<buy_categories2>) data.getExtras().getSerializable("cat");

Advertisement

Answer

buy_categories2 must be Serializable

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement