From e807bc3dc0f684212e43610a18f61e837a685c38 Mon Sep 17 00:00:00 2001 From: Ian Clelland Date: Mon, 13 Jan 2014 14:32:57 -0500 Subject: [PATCH] CB-5756: Android: Use WebView.evaluateJavascript for script injection on Android 4.4+ --- src/android/InAppBrowser.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java index 4efd99b..1a77c57 100644 --- a/src/android/InAppBrowser.java +++ b/src/android/InAppBrowser.java @@ -253,11 +253,16 @@ public class InAppBrowser extends CordovaPlugin { scriptToInject = source; } final String finalScriptToInject = scriptToInject; - // This action will have the side-effect of blurring the currently focused element this.cordova.getActivity().runOnUiThread(new Runnable() { + @SuppressLint("NewApi") @Override 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); + } } }); }