Put enum type in a bundle for intents
Enum:
public static enum MyEnum {
VALUE1,
VALUE2
}
Send value:
Intent intent = new Intent(this, MyActivity.class);
intent.putExtra(KEY, MyEnum.VALUE1);
startActivity(intent);
Restore value:
Bundle extras = getIntent().getExtras();
if ((extras != null) && (extras.containsKey(KEY))) {
MyEnum myEnum = (MyEnum)extras.getSerializable(KEY);
}
Written by Ignacio
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Android
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#