Last active
September 23, 2015 07:39
-
-
Save orhanobut/2fdc6a20c433932e431f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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