Skip to content

Instantly share code, notes, and snippets.

@scottyab
Created May 14, 2014 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottyab/a28083c82a475f9b207b to your computer and use it in GitHub Desktop.
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.
//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