WebView: how to avoid security alert from Google Play upon implementation of onReceivedSslError

To properly handle SSL certificate validation, change your code to invoke SslErrorHandler.proceed() whenever the certificate presented by the server meets your expectations, and invoke SslErrorHandler.cancel() otherwise. As email said, onReceivedSslError should handle user is going to a page with invalid cert, such like a notify dialog. You should not proceed it directly. For example, I … Read more

How to load html string in a webview?

To load your data in WebView. Call loadData() method of WebView wv.loadData(yourData, “text/html”, “UTF-8″); You can check this example http://developer.android.com/reference/android/webkit/WebView.html [Edit 1] You should add — \ — before — ” — for example –> name=\”spanish press\” below string worked for me String webData = “<!DOCTYPE html><head> <meta http-equiv=\”Content-Type\” ” + “content=\”text/html; charset=utf-8\”> <html><head><meta http-equiv=\”content-type\” … Read more

How does evaluateJavascript work?

There is an example of the evaluateJavascript method being used in this sample: https://github.com/GoogleChrome/chromium-webview-samples/tree/master/jsinterface-example Essentially if the javascript you execute in the WebView returns a value it’ll be passed in the callback. The main thing to note is that the String returned in OnReceiveValue is either a JSON Value, JSON Object or JSON Array depending … Read more

Android WebView “tel:” links show web page not found

OK so I solved the issue I think. I just needed to separate the URL overrides as follows: public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url.startsWith(“tel:”)) { Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(url)); startActivity(intent); view.reload(); return true; } view.loadUrl(url); return true; } Now my regular links work as well as the tel links. I … Read more

Memory leak in WebView

I conclude from above comments and further tests, that the problem is a bug in the SDK: when creating a WebView via XML layout, the activity is passed as the context for the WebView, not the application context. When finishing the activity, the WebView still keeps references to the activity, therefore the activity doesn’t get … Read more

Call Java function from JavaScript over Android WebView

I don’t think this is the best solution to get the javascript to execute java code. See here: If you want to expose native code to the HTML to be callable via javascript, do the following around your web view declaration: JavaScriptInterface jsInterface = new JavaScriptInterface(this); webView.getSettings().setJavaScriptEnabled(true); webView.addJavascriptInterface(jsInterface, “JSInterface”); Declare the class JavaScriptInterface: public class … Read more

How to set the initial zoom/width for a webview

The following code loads the desktop version of the Google homepage fully zoomed out to fit within the webview for me in Android 2.2 on an 854×480 pixel screen. When I reorient the device and it reloads in portrait or landscape, the page width fits entirely within the view each time. BrowserLayout.xml: <?xml version=”1.0″ encoding=”utf-8″?> … Read more

How to clear cookies and cache of webview on Android when not in webview?

I use the following approach in my app: @SuppressWarnings(“deprecation”) public static void clearCookies(Context context) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) { Log.d(C.TAG, “Using clearCookies code for API >=” + String.valueOf(Build.VERSION_CODES.LOLLIPOP_MR1)); CookieManager.getInstance().removeAllCookies(null); CookieManager.getInstance().flush(); } else { Log.d(C.TAG, “Using clearCookies code for API <” + String.valueOf(Build.VERSION_CODES.LOLLIPOP_MR1)); CookieSyncManager cookieSyncMngr=CookieSyncManager.createInstance(context); cookieSyncMngr.startSync(); CookieManager cookieManager=CookieManager.getInstance(); cookieManager.removeAllCookie(); cookieManager.removeSessionCookie(); cookieSyncMngr.stopSync(); cookieSyncMngr.sync(); } } Or … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)