I have two activities. Mainactivity.java and door1.java. On mainactivity.java I have a textview named plaintxt that I need to pass to textveiw named door1textview on door1.java. I have been trying for a while but no luck.
Asked
Active
Viewed 44 times
2 Answers
1
use below code in Mainactivity whether you need to pass data
Intent intent = new Intent(getBaseContext(), door1.class);
intent.putExtra("KEY", value);
startActivity(intent);
and you will be able to receive data in door1 activity like below
String value= getIntent().getStringExtra("KEY");
you can see more from here

Mahamudul Hasan
- 2,745
- 2
- 17
- 26
0
use intent to pass data between two activity like this MainActivity
String value=user_name.getText().toString().trim();
on Button Click
Intent theIntent = new Intent(this, SecondActivity.class);
theIntent.putExtra("name", value);
startActivity(theIntent);
SecondActivity
Intent i= getIntent();
i.getStringExtra("name");
another way to get data
Bundle extras = getIntent().getExtras();
String userName;
if (extras != null) {
userName = extras.getString("name");
// and get whatever type user account id is
}

Android Geek
- 8,956
- 2
- 21
- 35
-
can not get it to work – feroze Mar 08 '19 at 21:47