List of usage examples for org.apache.cordova AndroidWebView AndroidWebView
public AndroidWebView(Context context)
From source file:org.chromium.BackgroundActivity.java
License:Open Source License
@Override protected CordovaWebView makeWebView() { String r = preferences.getString("webView", null); CordovaWebView ret = null;/*from w ww .j a va 2 s. co m*/ Context webViewContext = this.getApplicationContext(); if (r != null) { try { Class<?> webViewClass = Class.forName(r); // Look for a constructor that takes separate Context and Activity parameters // - Allows for use of application context, which is definitely not an Activity, // as expected by some web view implementations (i.e. Crosswalk) Constructor<?> constructor; Object[] constructArgs; try { constructor = webViewClass.getConstructor(Context.class, Activity.class); constructArgs = new Object[] { webViewContext, this }; } catch (NoSuchMethodException e) { // No constructor with two separate parameters, so use the usual constructor // that takes only the Context constructor = webViewClass.getConstructor(Context.class); constructArgs = new Object[] { webViewContext }; } ret = (CordovaWebView) constructor.newInstance(constructArgs); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } } if (ret == null) { // If all else fails, return a default WebView ret = new AndroidWebView(webViewContext); } ret.init(delegatingCordovaInterface, pluginEntries, internalWhitelist, externalWhitelist, preferences); return ret; }