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

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -