How to pass an object from one activity to another on Android

后端 未结 30 3980
遇见更好的自我
遇见更好的自我 2020-11-21 04:03

I am trying to work on sending an object of my customer class from one Activity and display it in another Activity.

The code for t

30条回答
  •  甜味超标
    2020-11-21 05:10

    We can pass the object from one activity to another activity:

    SupplierDetails poSuppliersDetails = new SupplierDetails();
    

    Inside poSuppliersDetails we have some values. Now I am sending this object to target activity:

    Intent iPODetails = new Intent(ActivityOne.this, ActivityTwo.class);
    iPODetails.putExtra("poSuppliersDetails", poSuppliersDetails);
    

    How to get this in ACtivityTwo:

    private SupplierDetails supplierDetails;
        supplierDetails =(SupplierDetails) getIntent().getSerializableExtra("poSuppliersDetails");
    

提交回复
热议问题