I have an activity that when started needs access to two different ArrayLists. Both Lists are different Objects I have created myself.
Basically I need a way to pa
I like simple.
HAPPY and SAD.IntentFactory that creates your Intent for you. Pass it the Mode you want.IntentFactory uses the name of the Mode class as the name of the extra.IntentFactory converts the Mode to a String using name()onCreate use this info to convert back to a Mode.You could use ordinal() and Mode.values() as well. I like strings because I can see them in the debugger.
public class Fred extends Activity {
public static enum Mode {
HAPPY,
SAD,
;
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.betting);
Intent intent = getIntent();
Mode mode = Mode.valueOf(getIntent().getStringExtra(Mode.class.getName()));
Toast.makeText(this, "mode="+mode.toString(), Toast.LENGTH_LONG).show();
}
public static Intent IntentFactory(Context context, Mode mode){
Intent intent = new Intent();
intent.setClass(context,Fred.class);
intent.putExtra(Mode.class.getName(),mode.name());
return intent;
}
}