Back
How do you add an Enum object to an Android Bundle?
Enums are Serializable so there is no problems.
Given this enum:
enum YourEnum { TYPE1, TYPE2}
enum YourEnum {
TYPE1,
TYPE2
}
Bundle:
// putbundle.putSerializable("key", YourEnum.TYPE1);// get YourEnum yourenum = (YourEnum) bundle.get("key");
// put
bundle.putSerializable("key", YourEnum.TYPE1);
// get
YourEnum yourenum = (YourEnum) bundle.get("key");
Intent:
// putintent.putExtra("key", yourEnum);// getyourEnum = (YourEnum) intent.getSerializableExtra("key");
intent.putExtra("key", yourEnum);
yourEnum = (YourEnum) intent.getSerializableExtra("key");
31k questions
32.8k answers
501 comments
693 users