Skip to content Skip to sidebar Skip to footer

Pass The Value From 1st Activity To 2nd Activity In Android

As am getting article title on textview on first activity.how can i pass these textview to next activity... I have used below code: for ( j = 0; j

Solution 1:

if you want to use intents:

while going to the ListActivity pass data by..

intent.putExtra("Title", yourstring);
intent.putExtra("Content", yourstring);
startActivity(intent);

and to recover it in second activity use:

title= getIntent().getExtras().getString("Title");

...and so on..

Solution 2:

//to pass :
 Intent in = newIntent(MainActivity.this, SubCate.class);
in.putExtra("name", "Artical Name");  
 startActivity(in);


// to retrieve object in second ActivitygetIntent().getSerializableExtra("name");

Solution 3:

publicvoidonClick(View view)
 {
    publicvoidrun()
    {
            Intent i=new Intent(activity1.this,activity2.class);
            i.putExtra("somename", variable1);
            i.putExtra("somename1", variable2);         

    }
 }

In the second activity

Bundleextras= getIntent().getExtras();
    if (extras != null) {
        one= extras.getDouble("somename");
        two = extras.getDouble("somename2");

    }

Post a Comment for "Pass The Value From 1st Activity To 2nd Activity In Android"