I want to send the object of the customer class to another activity. So I want to show you in other activities What should I do?
public class Customer {
private String firstName, lastName, Address;
int Age;
public Customer(String fname, String lname, int age, String address) {
firstName = fname;
lastName = lname;
Age = age;
Address = address;
}
public String printValues() {
String data = null;
data = "First Name :" + firstName + " Last Name :" + lastName
+ + " Age : " + Age + " Address : " + Address;
return data;
}
}
You can implement Serializable
by inheriting the interface from the Customer class.
Then when you send it to the activity, send it to int.putExtra()
You can receive it through getSerializableExtra() from the activities you receive.
// When sending:
intent.putExtra("MyClass", obj);
// When I get it during an activity,
getIntent().getSerializableExtra("MyClass");
© 2024 OneMinuteCode. All rights reserved.