Debugger Debugger - 8 months ago 35
Java Question

How to use 'bundle' instead of 'intent.putExtra()' in Fragment in Android


I have used the following code for passing the value to other Activity classes:

intent.putExtra("book_arr", book_arr); // [putExtra(String *name*,Serializable *Value*)]

How to use like this code in Android Fragments?

I have tried the following code, but it is not supporting serialized value:

Bundle args =new Bundle();
args.putInt("book_arr", book_arr);


args.putSerializable("book_arr", book_arr);

If your book_arr (which should be bookArr) is a large array of heavy objects, consider making them Parcelable. You'll need to write additional code, but it's about x10 faster. (if it's not a big object you probably shouldn't bother). This page can be helpful