HF_MOBA
HF_MOBA
  • 发布:2018-06-20 16:38
  • 更新:2018-06-20 16:38
  • 阅读:1411

第三方插件开发中,无法回调onActivityResult

分类:HBuilder
    public String PluginTestFunctionSyncArrayArgu(IWebview pWebview, JSONArray array)  
    {  
        JSONArray newArray = null;  
        JSONObject retJSONObj = null;  
        try {  

            newArray = array.optJSONArray(0);  
            String inValue1 = newArray.getString(0);  
            String inValue2 = newArray.getString(1);  
            String inValue3 = newArray.getString(2);  
            String inValue4 = newArray.getString(3);  

            retJSONObj = new JSONObject();  
           // retJSONObj.putOpt("RetArgu1", inValue1);  
           // retJSONObj.putOpt("RetArgu2", inValue2);  
           // retJSONObj.putOpt("RetArgu3", inValue3);  
           // retJSONObj.putOpt("RetArgu4", inValue4);  

            final IApp _app = pWebview.obtainFrameView().obtainApp();  
            _app.registerSysEventListener(new ISysEventListener(){  
                @Override  
                public boolean onExecute(SysEventType pEventType, Object pArgs) {  

                    Object[] _args = (Object[])pArgs;  
                    int requestCode = (Integer)_args[0];  
                    int resultCode = (Integer)_args[1];  
                    Intent data = (Intent)_args[2];  
                    String change01 = data.getStringExtra("change01");  
                    if(pEventType == SysEventType.onActivityResult){  
                        _app.unregisterSysEventListener(this, SysEventType.onActivityResult);  
                        if (requestCode == 0) {  
                            JSONObject retJSONObj = new JSONObject();  
                            try{  
                                retJSONObj.putOpt("RetArgu1", change01);  
                            } catch (JSONException e1) {  
                                e1.printStackTrace();  
                            }  
                            JSUtil.wrapJsVar(retJSONObj); // mText01.setText(change01);  
                        }  
                    }  
                    return false;  
                }  

            }, SysEventType.onActivityResult);  

            Intent intent = new Intent(pWebview.getActivity(), CaptureActivity.class);  
            int requestCode = 0;  
            pWebview.getActivity().startActivityForResult(intent, requestCode);  
        } catch (JSONException e1) {  
            e1.printStackTrace();  
        }  

      //  return JSUtil.wrapJsVar(retJSONObj);  
        return "";  
    }
2018-06-20 16:38 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复