Last Updated: February 25, 2016
·
10.37K
· ignaciogs

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);

}