简体   繁体   中英

How much data do you send through intents/bundles to other activities/fragments?

For example, I have a Java Object that is a Recipe and it stores items such as recipe id, recipe name, recipe ingredients (ArrayList), recipe steps (ArrayList). Now, I have one activity and fragment A (shows recipe names in a recyclerview), which is loaded from a local asset Json file. Then, you click on a recipe name and it starts fragment B (through and interface with the activity), and it shows the Recipe information, would you pass a whole java object or would you just send something like the recipe id, then open up fragment B and reload data from the Json?

How much data is too much to pass to another activity/fragment?

Thanks folks for your input on this.

Edit: Hey guys thanks for your inputs, I did see the size limits of data being sent. I need to clarify a little bit, would you send the whole Recipe object through and intent or just pass the recipe id and the. Reload the data from the Json?

It's more like

500KB

The amount decreases slightly per Android version.

My advice is to only add very basic arguments to an Intent, If you need to transfer more, use application instance or create a singleton container holding the data you pass around.

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