[Solved] Variables to next activity [duplicate]


Pass value of string to Activity2:

button.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
    String a = editText.getText().toString();
    String b = editText2.getText().toString();

   Intent intent = new Intent(your_activity.this, Activity2.class);
   intent.putExtra("a_value", a);
   intent.putExtra("b_value", b);
   startActivity(intent);
 }
});

Retrieve the value in 2nd Activity:

public String user1;
public String user2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
user1 = getIntent().getExtras().getString("a_value");
user2 = getIntent().getExtras().getString("b_value");
          ...........
                    ...........

11

solved Variables to next activity [duplicate]