0

This is my class:

public class Asset extends  BaseModel implements Serializable{...}

and on an Activity I have this:

private void openAssignAssetIntent(String actionType){
    Intent assignAssetIntent = new Intent(this,AssignAssetActivity.class);
    assignAssetIntent.putExtra("currentAsset",currentAsset);
    startActivity(assignAssetIntent);
}

and I am trying to get this value("currentAsset") from another Activity like this:

Asset asst = (Asset) getIntent().getSerializableExtra("currentAsset");

But I am getting this exception:

java.lang.RuntimeException: Parcelable encountered IOException writing serializable object

What am I doing wrong?

Surya Prakash Kushawah
  • 3,185
  • 1
  • 22
  • 42
Fuluza
  • 109
  • 2
  • 13

1 Answers1

0

Use Bundle instead:

Bundle bundle = new Bundle();
bundle.putSerializable("currentAsset", currentAsset);
Intent assignAssetIntent = new Intent(this,AssignAssetActivity.class);
assignAssetIntent.putExtras(bundle);
startActivity(assignAssetIntent);

and then retrieve it like

Intent intent = this.getIntent();
Bundle bundle = intent.getExtras();

Asset asset = (Asset) bundle.getSerializable("currentAsset");

hope this helps

Pier Giorgio Misley
  • 5,305
  • 4
  • 27
  • 66