This is my code for the .putExtra:
String url = "test";
startActivity(new Intent(MainActivity.this, RelationshipRemoved.class)
.putExtra("userInfo", urlTwo));
How do I call the value urlTwo in another file?
This is my code for the .putExtra:
String url = "test";
startActivity(new Intent(MainActivity.this, RelationshipRemoved.class)
.putExtra("userInfo", urlTwo));
How do I call the value urlTwo in another file?
You can receive the value in another Activity
(not just another file) reading the value from the received bundle, like this:
String userInfo = getIntent().getStringExtra("userInfo");
or
String userInfo = getIntent().getExtras().getString("userInfo");
Example:
Activity
sending an intent:
Intent intent = new Intent(ActivityOne.this, ActivityTwo.class);
intent.putExtra("userInfo", "abcdef123456");
startActivity(intent);
ActivityTwo
receive the data stored :
String receivedValue = getIntent().getStringExtra("userInfo");
the variable receivedValue
will contain the string value "abcdef123456"
.