@Test public void testCallModuleMethod() throws Exception { WXModuleManager.callModuleMethod(instance.getInstanceId(),"test1","testMethod",null); WXModuleManager.callModuleMethod(instance.getInstanceId(),"test2","testMethod",null); }
static Object callModuleMethod(final String instanceId, String moduleStr, String methodStr, JSONArray args) { Log.e("haha", "moduleStr" + moduleStr); ModuleFactory factory = sModuleFactoryMap.get(moduleStr); if(factory == null){ WXLogUtils.e("[WXModuleManager] module factory not found."); return null; } final WXModule wxModule = findModule(instanceId, moduleStr,factory); if (wxModule == null) { return null; } WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(instanceId); wxModule.mWXSDKInstance = instance; final Invoker invoker = factory.getMethodInvoker(methodStr); try { if(instance != null) { IWXUserTrackAdapter userTrackAdapter = WXSDKManager.getInstance().getIWXUserTrackAdapter(); if(userTrackAdapter != null) { HashMap<String, Serializable> data = new HashMap<String, Serializable>(); data.put(MONITOR_ERROR_CODE, "101"); data.put(MONITOR_ARG, moduleStr + "." + methodStr); data.put(MONITOR_ERROR_MSG, instance.getBundleUrl()); userTrackAdapter.commit(instance.getContext(), null, IWXUserTrackAdapter.INVOKE_MODULE, null, data); } return dispatchCallModuleMethod(instance,wxModule,args,invoker); } else { WXLogUtils.e("callModuleMethod >>> instance is null"); return null; } } catch (Exception e) { WXLogUtils.e("callModuleMethod >>> invoke module:" + moduleStr + ", method:" + methodStr + " failed. ", e); return null; } finally { if (wxModule instanceof WXDomModule || wxModule instanceof WXTimerModule) { wxModule.mWXSDKInstance = null; } } }
WXModuleManager { static Object callModuleMethod(final String instanceId, String moduleStr, String methodStr, JSONArray args) { Log.e("haha", "moduleStr" + moduleStr); ModuleFactory factory = sModuleFactoryMap.get(moduleStr); if(factory == null){ WXLogUtils.e("[WXModuleManager] module factory not found."); return null; } final WXModule wxModule = findModule(instanceId, moduleStr,factory); if (wxModule == null) { return null; } WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(instanceId); wxModule.mWXSDKInstance = instance; final Invoker invoker = factory.getMethodInvoker(methodStr); try { if(instance != null) { IWXUserTrackAdapter userTrackAdapter = WXSDKManager.getInstance().getIWXUserTrackAdapter(); if(userTrackAdapter != null) { HashMap<String, Serializable> data = new HashMap<String, Serializable>(); data.put(MONITOR_ERROR_CODE, "101"); data.put(MONITOR_ARG, moduleStr + "." + methodStr); data.put(MONITOR_ERROR_MSG, instance.getBundleUrl()); userTrackAdapter.commit(instance.getContext(), null, IWXUserTrackAdapter.INVOKE_MODULE, null, data); } return dispatchCallModuleMethod(instance,wxModule,args,invoker); } else { WXLogUtils.e("callModuleMethod >>> instance is null"); return null; } } catch (Exception e) { WXLogUtils.e("callModuleMethod >>> invoke module:" + moduleStr + ", method:" + methodStr + " failed. ", e); return null; } finally { if (wxModule instanceof WXDomModule || wxModule instanceof WXTimerModule) { wxModule.mWXSDKInstance = null; } } } }
WXModuleManager { static Object callModuleMethod(final String instanceId, String moduleStr, String methodStr, JSONArray args) { Log.e("haha", "moduleStr" + moduleStr); ModuleFactory factory = sModuleFactoryMap.get(moduleStr); if(factory == null){ WXLogUtils.e("[WXModuleManager] module factory not found."); return null; } final WXModule wxModule = findModule(instanceId, moduleStr,factory); if (wxModule == null) { return null; } WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(instanceId); wxModule.mWXSDKInstance = instance; final Invoker invoker = factory.getMethodInvoker(methodStr); try { if(instance != null) { IWXUserTrackAdapter userTrackAdapter = WXSDKManager.getInstance().getIWXUserTrackAdapter(); if(userTrackAdapter != null) { HashMap<String, Serializable> data = new HashMap<String, Serializable>(); data.put(MONITOR_ERROR_CODE, "101"); data.put(MONITOR_ARG, moduleStr + "." + methodStr); data.put(MONITOR_ERROR_MSG, instance.getBundleUrl()); userTrackAdapter.commit(instance.getContext(), null, IWXUserTrackAdapter.INVOKE_MODULE, null, data); } return dispatchCallModuleMethod(instance,wxModule,args,invoker); } else { WXLogUtils.e("callModuleMethod >>> instance is null"); return null; } } catch (Exception e) { WXLogUtils.e("callModuleMethod >>> invoke module:" + moduleStr + ", method:" + methodStr + " failed. ", e); return null; } finally { if (wxModule instanceof WXDomModule || wxModule instanceof WXTimerModule) { wxModule.mWXSDKInstance = null; } } }  }
WXModuleManager { static Object callModuleMethod(final String instanceId, String moduleStr, String methodStr, JSONArray args) { Log.e("haha", "moduleStr" + moduleStr); ModuleFactory factory = sModuleFactoryMap.get(moduleStr); if(factory == null){ WXLogUtils.e("[WXModuleManager] module factory not found."); return null; } final WXModule wxModule = findModule(instanceId, moduleStr,factory); if (wxModule == null) { return null; } WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(instanceId); wxModule.mWXSDKInstance = instance; final Invoker invoker = factory.getMethodInvoker(methodStr); try { if(instance != null) { IWXUserTrackAdapter userTrackAdapter = WXSDKManager.getInstance().getIWXUserTrackAdapter(); if(userTrackAdapter != null) { HashMap<String, Serializable> data = new HashMap<String, Serializable>(); data.put(MONITOR_ERROR_CODE, "101"); data.put(MONITOR_ARG, moduleStr + "." + methodStr); data.put(MONITOR_ERROR_MSG, instance.getBundleUrl()); userTrackAdapter.commit(instance.getContext(), null, IWXUserTrackAdapter.INVOKE_MODULE, null, data); } return dispatchCallModuleMethod(instance,wxModule,args,invoker); } else { WXLogUtils.e("callModuleMethod >>> instance is null"); return null; } } catch (Exception e) { WXLogUtils.e("callModuleMethod >>> invoke module:" + moduleStr + ", method:" + methodStr + " failed. ", e); return null; } finally { if (wxModule instanceof WXDomModule || wxModule instanceof WXTimerModule) { wxModule.mWXSDKInstance = null; } } }  static boolean registerModule(final String moduleName, final ModuleFactory factory, final boolean global); static void onActivityCreate(String instanceId); static void onActivityStart(String instanceId); static void onActivityPause(String instanceId); static void onActivityResume(String instanceId); static void onActivityStop(String instanceId); static void onActivityDestroy(String instanceId); static boolean onActivityBack(String instanceId); static void onActivityResult(String instanceId,int requestCode, int resultCode, Intent data); static boolean onCreateOptionsMenu(String instanceId,Menu menu); static void onRequestPermissionsResult(String instanceId ,int requestCode, String[] permissions, int[] grantResults); static void destroyInstanceModules(String instanceId); static void createDomModule(WXSDKInstance instance); static void destoryDomModule(String instanceID); static WXDomModule getDomModule(String instanceId); static void reload(); }
WXModuleManager { static Object callModuleMethod(final String instanceId, String moduleStr, String methodStr, JSONArray args) { Log.e("haha", "moduleStr" + moduleStr); ModuleFactory factory = sModuleFactoryMap.get(moduleStr); if(factory == null){ WXLogUtils.e("[WXModuleManager] module factory not found."); return null; } final WXModule wxModule = findModule(instanceId, moduleStr,factory); if (wxModule == null) { return null; } WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(instanceId); wxModule.mWXSDKInstance = instance; final Invoker invoker = factory.getMethodInvoker(methodStr); try { if(instance != null) { IWXUserTrackAdapter userTrackAdapter = WXSDKManager.getInstance().getIWXUserTrackAdapter(); if(userTrackAdapter != null) { HashMap<String, Serializable> data = new HashMap<String, Serializable>(); data.put(MONITOR_ERROR_CODE, "101"); data.put(MONITOR_ARG, moduleStr + "." + methodStr); data.put(MONITOR_ERROR_MSG, instance.getBundleUrl()); userTrackAdapter.commit(instance.getContext(), null, IWXUserTrackAdapter.INVOKE_MODULE, null, data); } return dispatchCallModuleMethod(instance,wxModule,args,invoker); } else { WXLogUtils.e("callModuleMethod >>> instance is null"); return null; } } catch (Exception e) { WXLogUtils.e("callModuleMethod >>> invoke module:" + moduleStr + ", method:" + methodStr + " failed. ", e); return null; } finally { if (wxModule instanceof WXDomModule || wxModule instanceof WXTimerModule) { wxModule.mWXSDKInstance = null; } } }  static boolean registerModule(final String moduleName, final ModuleFactory factory, final boolean global); static void onActivityCreate(String instanceId); static void onActivityStart(String instanceId); static void onActivityPause(String instanceId); static void onActivityResume(String instanceId); static void onActivityStop(String instanceId); static void onActivityDestroy(String instanceId); static boolean onActivityBack(String instanceId); static void onActivityResult(String instanceId,int requestCode, int resultCode, Intent data); static boolean onCreateOptionsMenu(String instanceId,Menu menu); static void onRequestPermissionsResult(String instanceId ,int requestCode, String[] permissions, int[] grantResults); static void destroyInstanceModules(String instanceId); static void createDomModule(WXSDKInstance instance); static void destoryDomModule(String instanceID); static WXDomModule getDomModule(String instanceId); static void reload();  }