I have this enum like this
enum Status {READY, DISCONNECTED, RECEIVING, ... more }
I want to send a value of this enum over to another thread via a Bundle.
The other thread would like to extract enum value from the Bundle ,
How can this be done , smartly ?
Bundle createBundle(Status status);
and
Status getStatus(Bundle b);
Thanks,
Since Enum is serializable, we can just pack the enum into the bundle using:
public static String MY_ENUM = "MY_ENUM";
myBundle.putSerializable(MY_ENUM, enumValue);
To retrieve, use:
MyEnum myEnum = (MyEnum) myBundle.getSerializable(MY_ENUM);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With