Download file inside WebView

Have you tried? mWebView.setDownloadListener(new DownloadListener() { public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); } }); Example Link: Webview File Download – Thanks @c49

Android Webview – Completely Clear the Cache

I found an even elegant and simple solution to clearing cache WebView obj; obj.clearCache(true); http://developer.android.com/reference/android/webkit/WebView.html#clearCache%28boolean%29 I have been trying to figure out the way to clear the cache, but all we could do from the above mentioned methods was remove the local files, but it never clean the RAM. The API clearCache, frees up the … Read more

How can I display a pdf document into a Webview?

You can use Google PDF Viewer to read your pdf online: WebView webview = (WebView) findViewById(R.id.webview); webview.getSettings().setJavaScriptEnabled(true); String pdf = “http://www.adobe.com/devnet/acrobat/pdfs/pdf_open_parameters.pdf”; webview.loadUrl(“https://drive.google.com/viewerng/viewer?embedded=true&url=” + pdf);

How to change font face of Webview in Android?

There’s a working example of this in this project. It boils down to: In your assets/fonts folder, place the desired OTF or TTF font (here MyFont.otf) Create a HTML file that you’ll use for the WebView’s content, inside the assets folder (here inside assets/demo/my_page.html): <html> <head> <style type=”text/css”> @font-face { font-family: MyFont; src: url(“file:///android_asset/fonts/MyFont.otf”) } … Read more

how to get html content from a webview?

Actually this question has many answers. Here are 2 of them : This first is almost the same as yours, I guess we got it from the same tutorial. public class TestActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.webview); final WebView webview = (WebView) findViewById(R.id.browser); webview.getSettings().setJavaScriptEnabled(true); webview.addJavascriptInterface(new MyJavaScriptInterface(this), “HtmlViewer”); webview.setWebViewClient(new WebViewClient() … Read more

File Upload in WebView

This is a full solution for all android versions, I had a hard time with this too. public class MyWb extends Activity { /** Called when the activity is first created. */ WebView web; ProgressBar progressBar; private ValueCallback<Uri> mUploadMessage; private final static int FILECHOOSER_RESULTCODE=1; @Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { if(requestCode==FILECHOOSER_RESULTCODE) … Read more

not working in webview

As per your expectation, I think you want to enable heavy task in your WebView. For that you need to enable ChromeClient, mWebView.setWebChromeClient(new MyWebViewClient()); And your MyWebViewClient class will be, @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mWebView = (WebView) findViewById(R.id.activity_main_webview); // Force links and redirects to open in the WebView instead of in … Read more