Same object access in different activity?

I have a Java class say J.java

//j.java
class J
{


}

and I have 2 activity say A1,A2. In A1 I created a object of class J.

A1
{
  J obj = new J();
}

Question- I want to access the same object(obj) in A2.

A2
{
   obj // how can I access this object here? this is created in A1.
}

Answer

Implement Parcelable for that object. And send that object from A1 to A2 into intent extra.

Parcel data to pass between Activities using Parcelable classes is a very good example to implement Parcelable.

Leave a Reply

Your email address will not be published. Required fields are marked *