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");
1.2k questions
2.7k answers
501 comments
693 users