Try other constructors besides first

This commit is contained in:
Ian Clelland 2014-04-24 14:58:16 -04:00
parent 8e31ef7be6
commit df05f3a3c0

View File

@ -220,15 +220,17 @@ public class CordovaActivity extends Activity implements CordovaInterface {
Class webViewClass = Class.forName(r);
Constructor<CordovaWebView> [] webViewConstructors = webViewClass.getConstructors();
if(CordovaWebView.class.isAssignableFrom(webViewClass)) {
CordovaWebView webView = (CordovaWebView) webViewConstructors[0].newInstance(this);
return webView;
}
else
{
LOG.e(TAG, "The WebView Engine is NOT a proper WebView, defaulting to system WebView");
for (Constructor<CordovaWebView> constructor : webViewConstructors) {
try {
CordovaWebView webView = (CordovaWebView) constructor.newInstance(this);
return webView;
} catch (IllegalArgumentException e) {
LOG.d(TAG, "Illegal arguments; trying next constructor.");
}
}
}
LOG.e(TAG, "The WebView Engine is NOT a proper WebView, defaulting to system WebView");
} catch (ClassNotFoundException e) {
LOG.e(TAG, "The WebView Engine was not found, defaulting to system WebView");
} catch (InstantiationException e) {