mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 15:12:51 +08:00
CB-8386 Don't fallback on system webview if custom webview fails to construct
This commit is contained in:
parent
a2fed200fe
commit
137fe12c43
@ -217,40 +217,21 @@ public class CordovaActivity extends Activity implements CordovaInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the default web view object.
|
* Construct the CordovaWebView object.
|
||||||
*
|
*
|
||||||
* This is intended to be overridable by subclasses of CordovaIntent which
|
* Override this to customize the webview that is used.
|
||||||
* require a more specialized web view.
|
|
||||||
*/
|
*/
|
||||||
protected CordovaWebView makeWebView() {
|
protected CordovaWebView makeWebView() {
|
||||||
String r = preferences.getString("webView", null);
|
String webViewClassName = preferences.getString("webView", AndroidWebView.class.getCanonicalName());
|
||||||
CordovaWebView ret = null;
|
|
||||||
if (r != null) {
|
|
||||||
try {
|
try {
|
||||||
Class<?> webViewClass = Class.forName(r);
|
Class<?> webViewClass = Class.forName(webViewClassName);
|
||||||
Constructor<?> constructor = webViewClass.getConstructor(Context.class);
|
Constructor<?> constructor = webViewClass.getConstructor(Context.class);
|
||||||
ret = (CordovaWebView) constructor.newInstance((Context)this);
|
CordovaWebView ret = (CordovaWebView) constructor.newInstance((Context)this);
|
||||||
} 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(this);
|
|
||||||
}
|
|
||||||
ret.init(this, pluginEntries, internalWhitelist, externalWhitelist, preferences);
|
ret.init(this, pluginEntries, internalWhitelist, externalWhitelist, preferences);
|
||||||
return ret;
|
return ret;
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("Failed to create webview. ", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user