I want to pack an enum value in a Bundle and get as enum

android

Solution

Good question! I'm not aware of a way to pack enums directly. I always use this to pack:

int intValue = myEnum.ordinal();

then this to unpack:

MyEnum enumValue = MyEnum.values()[intValue];

Problem

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,

Original source

Related problems