1.Fragment中使用CordovaWebview
在github上有集成方法,
2.遇到的问题
1.cordova3.0以后cordovaWebview不能直接作为一个控件使用,
解决方案:可以使用systemwebview然后进行转型,代码如下:
systemWebView = (SystemWebView) rootView.findViewById(R.id.shop_webview_mall);
webView = new CordovaWebViewImpl(new SystemWebViewEngine(systemWebView));
Config.init(getActivity());
webView.init(new MyCordovaInterfaceImpl(getActivity()), parser.getPluginEntries(), parser.getPreferences());
webView.loadUrl("file:///android_asset/www/mallIndex.html#mallIndex");
2.插件startActivityResult的结果不会返回到插件中
解决方案:
第一步:在主activity中定义静态cordovaPlugin对象
public static CordovaPlugin activityResultCallback
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
LOG.d(TAG, "Incoming Result. Request code = " + requestCode);
// TODO Auto-generated method stub
CordovaPlugin callback = this.activityResultCallback;
if (callback != null) {
callback.onActivityResult(requestCode, resultCode, intent);
}
super.onActivityResult(requestCode, resultCode, intent);
}
第二步:在插件的startActivityForResult执行之前为此CordovaPlugin赋值
FlycoMainTabActivity.activityResultCallback = (CordovaPlugin)this;
this.cordova.startActivityForResult((CordovaPlugin) this, intent, PHOTOLIBRARY);