ANDROID TUTORIAL: PASS STRING DATA FROM ONE ACTIVITY TO ANOTHER ACTIVITY

Sometimes, for specific purposes, you may want to transfer data from one activity to another activity in Android. In this Android tutorial, I explain how to pass a string from one activity to another.

Here, you need two activities. The first activity consists of a EditText and a Button. When the button is pressed, we send a string, which is the input you have given in the EditText and the string will be shown as a TextView in the second activity.

Here’s the XML file of first activity.

activity_main xml
activity_main xml

And here is the java code for the first activity.

Follow the Java code given below for second activity to receive the string.

That’s it. Now run your app, type any text and press send button to see the typed text as TextView in the second activity.

Leave a Reply