CB-5756: Android: Use WebView.evaluateJavascript for script injection on Android 4.4+

This commit is contained in:
Ian Clelland 2014-01-13 14:32:57 -05:00
parent 21fe13e809
commit 255c5269c3

View File

@ -251,11 +251,16 @@ public class InAppBrowser extends CordovaPlugin {
scriptToInject = source; scriptToInject = source;
} }
final String finalScriptToInject = scriptToInject; final String finalScriptToInject = scriptToInject;
// This action will have the side-effect of blurring the currently focused element
this.cordova.getActivity().runOnUiThread(new Runnable() { this.cordova.getActivity().runOnUiThread(new Runnable() {
@SuppressLint("NewApi")
@Override @Override
public void run() { public void run() {
inAppWebView.loadUrl("javascript:" + finalScriptToInject); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
// This action will have the side-effect of blurring the currently focused element
inAppWebView.loadUrl("javascript:" + finalScriptToInject);
} else {
inAppWebView.evaluateJavascript(finalScriptToInject, null);
}
} }
}); });
} }