public static CordovaWebViewEngine createEngine(Context context, CordovaPreferences preferences) { String className = preferences.getString("webview", SystemWebViewEngine.class.getCanonicalName()); try { Class<?> webViewClass = Class.forName(className); Constructor<?> constructor = webViewClass.getConstructor(Context.class, CordovaPreferences.class); return (CordovaWebViewEngine) constructor.newInstance(context, preferences); } catch (Exception e) { throw new RuntimeException("Failed to create webview. ", e); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //Set up the webview ConfigXmlParser parser = new ConfigXmlParser(); parser.parse(this); SystemWebView webView = (SystemWebView) findViewById(R.id.cordovaWebView); webInterface = new CordovaWebViewImpl(new SystemWebViewEngine(webView)); webInterface.init(cordovaInterface, parser.getPluginEntries(), parser.getPreferences()); webView.loadUrl(parser.getLaunchUrl()); }