android - IntDef through an intent -
any ideas in best way send intdef through intent?
ps: if send int loose type check, main goal of having intdef
your intdef not available @ runtime. way go encapsulate generation of intent in intent-receiving activity.
public class myactivity extends activity { private static final string key_navigation_mode = "navigation_mode"; private @navigationmode int mnavigationmode; public static intent getstartintent(context context, @navigationmode string navigationmode) { intent intent = new intent(context, myactivity.class); intent.putextra(key_navigation_mode, navigationmode); return intent; } @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); //noinspection wrongconstant safe because saved in #getstartintent mnavigationmode = getintent().getintextra(key_navigation_mode, navigation_mode_your_default); } }
Comments
Post a Comment