Send Data from One Activity to Another – Activity Intent

Many people told me that you should teach android from the scratch , I told them yes I will and I am , So come to the point here is your tutorial after knowing basic widgets in Android I am going to teach you how to switch between one Activity to another and then send data from one Activity to another. Data or values can be send from one Activity to another using intent.putExtras(key,value).

This is possible via Intent and it is of two type Implicit Intent and Explicit Intent .What’s the difference between Implicit Intent and Explicit Intent ? have a look . Implicit Intent is not specified the component.

Lets take an example – “Java file should call implicit Intent asked the system to perform the service without telling the system  which Java file do the service.

Explicit Intent is something which gives the name of the componet .Lets take an example –

Download Code

Lets start with design part for this project , start with screen1.xml . you have to take two editText ,Two TextView and one Button that’s very simple and  already teach that stuff see my previous tutorials . screen1.xml

Now prepare second screen so that if you get values from first Activity then where it will go. so for that you have to take three TextView  and one Button. screen2.xml

Now have a look on Java part for this application , It is very simple. we are using the concept that we are getting value from EditText and then using i.putExtras(key,getValue from edittext) values can be send .

Now you have to code for SecondActivity,java. On the receiver side we are having getStringExtras(key) .

And yes one more thing please update your AndroidManifest.xml 

Now Run your project and yeah ! here is you Output – Intent1 intent2 For more updates please do like Our page and post here any Query :p

  • Birendra verma

    awesome tutorial .easy to understand the concept .
    sir i have some problem . i want to display student details in listview of another activity when view_all button is clicked .
    sir please help me

    • Hi Birendra Verma , Thanks keep reading ,
      Before starting just tell me what is your need !!
      As i can understand from question you want to show listview on click of button ?
      So first you have to make sure you have array/arraylist/any collection that can feed your listview , and just inflate it .for more detail visit –
      for custom listview –

      else you can check it on google that simple listview example android .