pass list to intent in android java

Solutions on MaxInterview for pass list to intent in android java by the best coders in the world

showing results for - "pass list to intent in android java"
Juan Diego
23 Jan 2020
1First, make the class of the list implement Serializable.
2
3public class Object implements Serializable{}
4Then you can just cast the list to (Serializable). Like so:
5
6List<Object> list = new ArrayList<Object>();
7myIntent.putExtra("LIST", (Serializable) list);
8And to retrieve the list you do:
9
10Intent i = getIntent();
11list = (List<Object>) i.getSerializableExtra("LIST");
12
Mads
26 Jan 2020
1Intent intent = new Intent(getApplicationContext(),YourActivity.class);
2Bundle bundle = new Bundle();
3bundle.putParcelable("data", sharedBookingObject);
4intent.putExtras(bundle);
5startActivity(intent);