-1

I know that there are 2 ways to do this, Parcelable and Serializable. Another method (a bad one) is static variables.

An entry of that list can be instance of class A or class B.

I tried passing the list using Parcelable and Serializable with no success, since the class Object doesn't implement anything.

// When setting:

List<Object> liveMatchList = DataCenter.getMatchesByDate(context, date,
                    tIdsAsString, true);
intent.putExtra("SER", liveMatchList);

// When getting:

List<Object> matchesList = (List<Object>)intent.getSerializableExtra("SER");

How to do this please?

Hamzeh Soboh
  • 7,070
  • 5
  • 37
  • 54

2 Answers2

0

try with below code:

Intent intent = new Intent(context,DESTINATION ACTIVITY.class);
intent.putExtra("data",YOUR ARRAY OF OBJECT)
startActivity(intent);

//Getting data in another activity

ARRAY OF OBJECT = (ArrayList<String>) this.getIntent().getSerializableExtra("data"); 

//here I` have used Arraylist to explain you.

Pratik Dasa
  • 7,103
  • 4
  • 26
  • 43
0
Intent i = getIntent();  
stock_list = i.getStringArrayListExtra("stock_list");
and 
stock_list = getIntent().getStringArrayListExtra("stock_list");

Passing ArrayList through Intent

Community
  • 1
  • 1
Naveen Tamrakar
  • 3,274
  • 1
  • 15
  • 28