Java Code Examples for android.webkit.WebView#clearFocus()
The following examples show how to use
android.webkit.WebView#clearFocus() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InAppBrowser.java From ultimate-cordova-webview-app with MIT License | 6 votes |
public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); // CB-10395 InAppBrowser's WebView not storing cookies reliable to local device storage if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { CookieManager.getInstance().flush(); } else { CookieSyncManager.getInstance().sync(); } // https://issues.apache.org/jira/browse/CB-11248 view.clearFocus(); view.requestFocus(); try { JSONObject obj = new JSONObject(); obj.put("type", LOAD_STOP_EVENT); obj.put("url", url); sendUpdate(obj, true); } catch (JSONException ex) { LOG.d(LOG_TAG, "Should never happen"); } }
Example 2
Source File: InAppBrowser.java From ultimate-cordova-webview-app with MIT License | 6 votes |
public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); // CB-10395 InAppBrowser's WebView not storing cookies reliable to local device storage if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { CookieManager.getInstance().flush(); } else { CookieSyncManager.getInstance().sync(); } // https://issues.apache.org/jira/browse/CB-11248 view.clearFocus(); view.requestFocus(); try { JSONObject obj = new JSONObject(); obj.put("type", LOAD_STOP_EVENT); obj.put("url", url); sendUpdate(obj, true); } catch (JSONException ex) { LOG.d(LOG_TAG, "Should never happen"); } }
Example 3
Source File: WebViewHelper.java From GeneratePicture with Apache License 2.0 | 5 votes |
public void getSelectedData(WebView webView) { // String js = "(function getSelectedText() {" + // "var txt;" + // "if (window.getSelection) {" + // "txt = window.getSelection().toString();" + // "} else if (window.document.getSelection) {" + // "txt = window.document.getSelection().toString();" + // "} else if (window.document.selection) {" + // "txt = window.document.selection.createRange().text;" + // "}" + // "JSInterface.getText(txt);" + // "})()"; String js = "(function getSelectedText() {" + "var txt;" + "if (window.getSelection) {" + "var range=window.getSelection().getRangeAt(0);" + "var container = window.document.createElement('div');" + "container.appendChild(range.cloneContents());" + "txt = container.innerHTML;" + "} else if (window.document.getSelection) {" + "var range=window.getSelection().getRangeAt(0);" + "var container = window.document.createElement('div');" + "container.appendChild(range.cloneContents());" + "txt = container.innerHTML;" + "} else if (window.document.selection) {" + "txt = window.document.selection.createRange().htmlText;" + "}" + "JSInterface.getText(txt);" + "})()"; // calling the js function if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { webView.evaluateJavascript("javascript:" + js, null); } else { webView.loadUrl("javascript:" + js); } webView.clearFocus(); }
Example 4
Source File: InAppBrowser.java From cordova-plugin-inappbrowser with Apache License 2.0 | 5 votes |
public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); // Set the namespace for postMessage() if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) { injectDeferredObject("window.webkit={messageHandlers:{cordova_iab:cordova_iab}}", null); } // CB-10395 InAppBrowser's WebView not storing cookies reliable to local device storage if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { CookieManager.getInstance().flush(); } else { CookieSyncManager.getInstance().sync(); } // https://issues.apache.org/jira/browse/CB-11248 view.clearFocus(); view.requestFocus(); try { JSONObject obj = new JSONObject(); obj.put("type", LOAD_STOP_EVENT); obj.put("url", url); sendUpdate(obj, true); } catch (JSONException ex) { LOG.d(LOG_TAG, "Should never happen"); } }