Android webview loadDataWithBaseURL how load images from assets?

try like this WebView webview = (WebView)this.findViewById(R.id.webview); String html = “<html><head><title>TITLE!!!</title></head>”; html += “<body><h1>Image?</h1><img src=\”icon.png\” /></body></html>”; webview.loadDataWithBaseURL(“file:///android_res/drawable/”, html, “text/html”, “UTF-8”, null); For more information try this link perfect LoadDataWithBaseurl

How to detect scrollend of webview in android?

@Override protected void onScrollChanged(int l, int t, int oldl, int oldt) { int height = (int) Math.floor(this.getContentHeight() * this.getScale()); int webViewHeight = this.getMeasuredHeight(); if(this.getScrollY() + webViewHeight >= height){ Log.i(“THE END”, “reached”); } super.onScrollChanged(l, t, oldl, oldt); } This logic works fine for a webview.

How to manage cookies with UIWebView in Swift

Try this code: SEE COOKIES STORED if let cookies = NSHTTPCookieStorage.sharedHTTPCookieStorage().cookies { for cookie in cookies { NSLog(“\(cookie)”) } } DELETE STORED COOKIES var storage : NSHTTPCookieStorage = NSHTTPCookieStorage.sharedHTTPCookieStorage() for cookie in storage.cookies as! [NSHTTPCookie]{ storage.deleteCookie(cookie) } swift 2.0 let storage = NSHTTPCookieStorage.sharedHTTPCookieStorage() for cookie in storage.cookies! { storage.deleteCookie(cookie) } Swift 3.0 if let cookies … Read more

Android webView saveState

This can be handled by overrwriting onSaveInstanceState(Bundle outState) in your activity and calling saveState from the webview: @Override protected void onSaveInstanceState(Bundle outState) { webView.saveState(outState); super.onSaveInstanceState(outState); } Then recover this in your onCreate after the webview has been re-inflated of course: @Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.blah); WebView webview = (WebView)findViewById(R.id.webview); if (savedInstanceState … Read more

android – how to prevent webview to load when no internet connection

I have used the following in my projects: DetectConnection.Java import android.content.Context; import android.net.ConnectivityManager; public class DetectConnection { public static boolean checkInternetConnection(Context context) { ConnectivityManager con_manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); return (con_manager.getActiveNetworkInfo() != null && con_manager.getActiveNetworkInfo().isAvailable() && con_manager.getActiveNetworkInfo().isConnected()); } } Main code: if (!DetectConnection.checkInternetConnection(this)) { Toast.makeText(getApplicationContext(), “No Internet!”, Toast.LENGTH_SHORT).show(); } else { wv = (WebView) findViewById(R.id.donate_webView1); c … Read more

Webview shows error “Didn’t find class “android.webkit.RenderProcessGoneDetail”

It appears to be a bug, more details here: https://groups.google.com/a/chromium.org/forum/#!topic/android-webview-dev/m0EtO3IXNn0 On N+ new ART logging appears to have been introduced letting app developers know about certain binary compatibility problems in their code. Unfortunately, this is triggering for some of the API-level guarded code in WebView. One example is “Failed resolution of: Landroid/webkit/RenderProcessGoneDetail;”, which is triggered … Read more

How can I programmatically take a screenshot of a webview, capturing the full page?

Try this one import java.io.FileOutputStream; import android.app.Activity; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Picture; import android.os.Bundle; import android.view.Menu; import android.webkit.WebView; import android.webkit.WebViewClient; public class MainActivity extends Activity { WebView w; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); w = new WebView(this); w.setWebViewClient(new WebViewClient() { public void onPageFinished(WebView view, String url) { Picture picture = view.capturePicture(); Bitmap … Read more