Skip to content

Instantly share code, notes, and snippets.

@orhanobut
Last active September 23, 2015 07:39
Show Gist options
  • Save orhanobut/2fdc6a20c433932e431f to your computer and use it in GitHub Desktop.
Save orhanobut/2fdc6a20c433932e431f to your computer and use it in GitHub Desktop.
// sender
public class LoginActivity extends Activity {
void displayHome() {
startActivity(HomeActivity.newIntent(this, user));
}
}
// receiver
public class HomeActivity extends Activity {
private static final String KEY_USER = "KEY_USER";
public static Intent newIntent(Context context, String user) {
Intent intent = new Intent(context, HomeActivity.class);
intent.putExtra(KEY_USER, user);
return intent;
}
@Override public void onCreate(Bundle bundle) {
...
String user = getIntent().getStringExtra(KEY_USER);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment