0

if i were to pass a custom object to another activity/service using Parcelable using

    ObjectA obj = new ObjectA();

    // Set values etc.

    Intent i = new Intent(this, MyActivity.class);
    i.putExtra("com.package.ObjectA", obj);

    startActivity(i);

and then read it in the new activity/service using

    Bundle b = getIntent().getExtras();
    ObjectA obj =b.getParcelable("com.package.ObjectA");

and were to then change the values of the objects fields in the first activity.

would the object in the second activity reflect this or does it act as a clone of the first object and never change?

if the second object never changes what would be the simplest way to implement this sort of behavior?

thanks in advance

1 Answers1

0

No, changes will not be reflected into the original object. You may say that it acts as a clone of the first object, if you want. If you need to return a modified object, then do so. See about setResult, to which you may pass an Intent filled of return data (the modified object, in your case). Use it in conjunction with startActivityForResult.

K-ballo
  • 80,396
  • 20
  • 159
  • 169