Android Example Passing Variables Between Activities using Intent

Here is an example of passing variables between activities using Intent. It is easy to add extra inside an intent but unless you do it a lot then you may after reference an example.

Activity Creating the Intent and Starting the other Activity  (Activity1):

   Intent next = new Intent(EditSchedule.this, ConfirmSchedule.class);
   next.putExtra("amount", amountContribute.getText().toString());

Grabbing the variables in the next Activity from Activity1

public class Activity2 extends Activity{

	String duration ="", frequency = "", taxYear = "", amount = "", startDate = "";

	public void onCreate(Bundle savedInstanceState) {

	    Bundle b = getIntent().getExtras();  

            * also you can do:  
            * duration = getIntent().getExtras().getString("duration");

            if(b != null){  // may not be needed in your case
               duration = b.getString("duration");
	       frequency = b.getString("frequency");
               taxYear = b.getString("taxYear");
	       amount = b.getString("amount");
               startDate = b.getString("startDate");

            * also you can do (not tested):  
            * ((TextView) findViewById("duration"));

	    ((TextView) findViewById(;
	    ((TextView) findViewById("??");
	    ((TextView) findViewById(;
	    ((TextView) findViewById(;
	    ((TextView) findViewById(;
	    ((TextView) findViewById(;
	    ((TextView) findViewById(;	    

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Graveyard Database Logo

Has everything you want to know about grave yards. Plus has many celebrites and world leaders graves. Pssst it is my other site

Google + Profile
Check out Android Photo Mapping, its a app/site I been working on
Fabulou wholesale Petr Mrazek jersey is back. Best choice to get the wholesale Petr Mrazek jersey is suitable for all style of people.