intent bundle enum

Enums are Serializable so there is no issue.
Given the following enum:

enum YourEnum { TYPE1, TYPE2}

Bundle:

// put
bundle.putSerializable("key", YourEnum.TYPE1);
// get 
YourEnum yourenum = (YourEnum) bundle.get("key");

Intent:

// put
intent.putExtra("key", yourEnum);
// get
yourEnum = (YourEnum) intent.getSerializableExtra("key");

Not Good

enum.ordinal() = int
values()[int] = enum

你可能感兴趣的:(intent bundle enum)