Android Passing Data Between Activities

As you can see in the previous post how we can Link Activities. But one of the most important thing is when we launch one activity to another, at the same time we may need some data passing to another activity too. For example, A product information or A person name and his/her details.
In this article I am going to show you, how we can pass the data between activities.

Passing Primitive Data types using Intent

To pass primitive data types using Intent class you can use putExtra() method. Like String, Integer or Boolean.
See the following code.

When launch the target Activity by using Intent object, you can get all the data attached to the Intent object.
Let’s see how.

Passing Data in Bundle object using Intent

You can also pass the data in Bundle object using Intent class. The Bundle object is like dictionary object. Just Define Bundle object and populate object with keys and its values. And pass the bundle using putExtras() method.
See the code.

After launch targeted Activity to retrieve passed data in bundle object. use getExtras() method.

Download Source of working example.

1 reply

Trackbacks & Pingbacks

  1. […] the preceding article I have shown, How to Pass Data Between Activities. In this article I am going to cover how we can Pass an Object between Activities. See the […]

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

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