@ReactMethod public void initialize() { ReactApplication application = (ReactApplication)getReactApplicationContext() .getCurrentActivity() .getApplication(); DevSupportManager devSupportManager = application .getReactNativeHost() .getReactInstanceManager() .getDevSupportManager(); devSupportManager.addCustomDevOption("Log AsyncStorage", new DevOptionHandler() { @Override public void onOptionSelected() { getReactApplicationContext() .getJSModule(RCTNativeAppEventEmitter.class) .emit("LogAsyncStorage", null); } }); }
/** * Demonstrates how to add a custom option to the dev menu. * https://stackoverflow.com/a/44882371/3968276 */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); MainApplication application = (MainApplication) getApplication(); ReactNativeHost reactNativeHost = application.getReactNativeHost(); ReactInstanceManager reactInstanceManager = reactNativeHost.getReactInstanceManager(); DevSupportManager devSupportManager = reactInstanceManager.getDevSupportManager(); devSupportManager.addCustomDevOption("Custom dev option", new DevOptionHandler() { @Override public void onOptionSelected() { Toast.makeText(MainActivity.this, "Hello from custom dev option", Toast.LENGTH_SHORT).show(); } }); }
/** * Add option item to dev settings dialog displayed by this manager. In the case user select given * option from that dialog, the appropriate handler passed as {@param optionHandler} will be * called. */ @Override public void addCustomDevOption( String optionName, DevOptionHandler optionHandler) { mCustomDevOptions.put(optionName, optionHandler); }
@Override public void addCustomDevOption(String optionName, DevOptionHandler optionHandler) { }