简体   繁体   中英

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");

buy_categories2 must be Serializable

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM