0 votes
1 view
in Java by (2.6k points)

How do you add an Enum object to an Android Bundle?

1 Answer

0 votes
by (41k points)

Enums are Serializable so there is no problems.

Given this 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");

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Oct 23 in Java by Anvi (8.2k points)
0 votes
1 answer
asked Oct 17 in Java by Anvi (8.2k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...