Created
May 14, 2014 16:23
-
-
Save scottyab/a28083c82a475f9b207b to your computer and use it in GitHub Desktop.
When using Intent extras, pass an Id rather than the object as Intent extras 'could' be intercepted and read be a malicious app.
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
//bad passing the whole paracable object | |
public static Intent getStartingIntent(Context context, | |
User user) { | |
Intent i = new Intent(context, UserDetailsActivity.class); | |
i.putExtra(EXTRA_USER, user); | |
return i; | |
} | |
//better to pass just the ID to lookup the user details | |
public static Intent getStartingIntent(Context context, | |
String userId) { | |
Intent i = new Intent(context, UserDetailsActivity.class); | |
i.putExtra(EXTRA_USER_ID, userId); | |
return i; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment