There will be two options
using Intent
Using preferences
using Intent
pass the parameter to the next acytivity
Intent n = new Intent(login.this, Home.class);
n.putExtra("UserName", _username);
startActivity(n);
In your Home page:
Bundle extras = getIntent().getExtras();
if(extras!=null)
{
userName.setText("Welcome to "+extras.getString("UserName"));
}
Using Preferences
In Your login Page
preferences = PreferenceManager.getDefaultSharedPreferences(this);
Editor edit = preferences.edit();
edit.putString("pref_userName", userName);
edit.commit();
In your Home page
pref_userName = preferences.getString("pref_userName", "n/a");
userName.setText("Welcome to "+pref_userName);
If you have more activities and want to show username in all activities then I suggest to use Preferences.
So this will be simple and one more thing is
If you are using preferences then don't forget to putstring null
when you are logout from the app