0

I want to send a list of object form a class that I have created through intent from one application, and get this list in one other.

I tried this :

Intent i = new Intent();

i=getActivity().getPackageManager().getLaunchIntentForPackage(getString(R.string.package_app));

ArrayList<MyClass> list = new ArrayList<MyClass>();

i.setAction(Intent.ACTION_SEND);

i.putExtra(Intent.EXTRA_TEXT, list);

i.setType("text/plain");

And to get it i have done this :

Intent receivedIntent = getIntent();

ArrayList<MyClass> getList = new ArrayList<MyClass>();

getList=(ArrayList<MyClass>)receivedIntent.getSerializableExtra(Intent.EXTRA_TEXT);

startActivity(i);

But i have an exception when i want to get the list

Herry
  • 7,037
  • 7
  • 50
  • 80
eterpoir
  • 11
  • 2

1 Answers1

1

According to your stack trace you need to make the MyClass serializable.

Then you can pass the list of MyClass to second activity.

This can be as shown below:

class MyClass implements Serializable
{
//your implementation
}

In your 1st activity you need to do something like this:

Intent i = new Intent(context,secondactivity.class);

ArrayList<MyClass> list = new ArrayList<MyClass>();
i.putExtra("listdata",list);

In your 2nd activity you need to do something like this:

Intent receivedIntent = getIntent();

getList=receivedIntent.getSerializableExtra("listdata",null);

Hope this helps...