how to send a class in intent android studoi code example

Example 1: pass list to intent in android java

First, make the class of the list implement Serializable.

public class Object implements Serializable{}
Then you can just cast the list to (Serializable). Like so:

List list = new ArrayList();
myIntent.putExtra("LIST", (Serializable) list);
And to retrieve the list you do:

Intent i = getIntent();
list = (List) i.getSerializableExtra("LIST");

Example 2: android pass object to activity

Intent intent = new Intent(fromClass.this,toClass.class).putExtra("myCustomerObj",customerObj);

Tags:

Misc Example