Passing Objects in Android, Passing Objects in Android between Activities, AndroidMkab, AndroidMkab

Passing Objects in Android between Activities

In this tutorial, I will show you the method of Passing Objects in Android. Passing Objects in Android may be done for objects like Strings, User Input data, Web URLs etc.,

When we do Passing Objects in Android data from one Activity to another Activity values of Strings, User Input data or web URLs are passed from First Activity to Second Activity. Passing Objects in Android can be done by using Implicit Intent which is one of the Intent types.

An Implicit Intent is a type of Intent where we know the destination is. That is we know which activity we are going next.

The output of this method will be like below picture.

Passing Objects in Android, Passing Objects in Android between Activities, AndroidMkab, AndroidMkab


Note: Watch Below Video for better understanding of the code.

  • Create a new Android Studio Project

  • Add below line in dependencies of your App Gradle.
  • In activity_main.xml file copy below code by removing all existing code.
  • In above activity_main.xml file, I have given three input fields for Name, Email, and Phone number and a Button to Save the data. But no data is saved here. To button, we will add intent which will pass objects to another activity.
  • Now in file paste below code in the onCreate() method.
  • Now Create a new class with name  and paste below code by removing everything except the first line
  • Next, add above Activity to you AndroidManifest file by pasting below line in <application> tag.
  • And create a new Layout file with name activity_second.xml and paste below code by replacing everything in it.
  • In above activity_second.xml  file, I added only two things one TextView to show values of objects passed from and a Button to go back to previous activity.
  • Next, add below code to the onCreate() method of
  • Now run the code on Android device or emulator. Fill the form like below

Passing Objects in Android, AndroidMkab

  • Now press Save Button you will move to second activity and see output like below Image.

Passing Objects in Android, AndroidMkab

  • If you like this post share it. Because sharing is caring.

0 Reviews

Write a Review