Skip to content Skip to sidebar Skip to footer

Unable To Pass 1st Activity's Textview Value To 2nd Activity's Textview Through Getintent()

I am trying to pass textview value between different activities, here is my code that i've tried: LoginActivity.java public class LoginActivity extends Activity { Button btnLo

Solution 1:

Try using getExtras()....

Bundle i = getIntent().getExtras();
    String a = i.getStringExtra("level");
    Log.d("TAG1", String.valueOf(a));
    textView.setText(String.valueOf(a));

Solution 2:

String a = getIntent().getExtras().getString("level");
 textView.setText(String.valueOf(a));

Solution 3:

Activity 1:

Intentii=newIntent(this, ShareOnFacebook.class);
Bundle bundle=newBundle();
bundle.putString("message", facebookMessage);
startActivity(ii.putExtras(bundle))

Activity2:
StringfacebookMessage= getIntent().getStringExtra("message"); 
TextViewtxtView= (TextView) findViewById(R.id.your_resource_textview);    
txtView.setText(message);

Solution 4:

you are passing bundle in the intent and retrieving intent extra. Either you pass bundle and retrieve bundle or pass intent extra and retrieve the same. In you code while calling the StudentActivity try below code. i.e

  Intent ii = newIntent(LoginActivity.this, StudentActivity.class);
  ii.putExtra("level", a);         
  startActivity(ii);

Post a Comment for "Unable To Pass 1st Activity's Textview Value To 2nd Activity's Textview Through Getintent()"