Reputation: 57
I am displaying a username using Intent but I want to append welcome before its name I have tried this, so far but I am unable to get the result that I want.
myIntent.putExtra("User", username.getText().toString());
I am adding welcome so it comes before the username
myIntent.putExtra("Welcome"+"User", username.getText().toString());
it's not working please suggest what should be done!!!!
Upvotes: 0
Views: 367
Reputation: 6899
In putExtra("key", value)
method first parameter is key and the second is value and the key should be the same to get the value in the next activity
You Instead of
myIntent.putExtra("Welcome"+"User", username.getText().toString());
use
myIntent.putExtra("User", "Welcome "+username.getText().toString());
In the next activity use the below line, it will return the complete message
Intent intent = getIntent();
String data = intent.getStringExtra("User");
Upvotes: 1