webviewclient

shouldOverrideUrlLoading does not work/catch link clicks while page is loading

情到浓时终转凉″ 提交于 2019-12-02 20:49:58
I am using WebViewClient.shouldOverrideUrlLoading to catch any link clicks in the WebView. This works about 95% of the time, but sometimes it is simply not called. I have noticed it in these three circumstances: When the link points to the page they are already on. This one isn't a really big deal, and there is a bug reported for it . While the page is still loading, if the user clicks a link, it rarely catches it. It will just open the link without ever calling shouldOverrideUrlLoading . Randomly. While experimenting with this over the last couple months I have noticed that sometimes it just

Disable Android WebView/WebViewClient Initiated favicon.ico Request

旧街凉风 提交于 2019-12-01 17:29:50
How can I disable the Android WebView/WebViewClient from sending out a request for favicon.ico when I call WebView.loadUrl()? I can see the call being made while profiling requests via CharlesProxy. I do not own the HTML content that I am displaying in the WebView. My research has turned up a lot of results on workarounds from the server side but these won't work for me. ventura8 for me the complete solution was: @Override public WebResourceResponse shouldInterceptRequest(WebView view, String url) { if(url.toLowerCase().contains("/favicon.ico")) { try { return new WebResourceResponse("image

Disable Android WebView/WebViewClient Initiated favicon.ico Request

我的梦境 提交于 2019-12-01 15:02:18
问题 How can I disable the Android WebView/WebViewClient from sending out a request for favicon.ico when I call WebView.loadUrl()? I can see the call being made while profiling requests via CharlesProxy. I do not own the HTML content that I am displaying in the WebView. My research has turned up a lot of results on workarounds from the server side but these won't work for me. 回答1: for me the complete solution was: @Override public WebResourceResponse shouldInterceptRequest(WebView view, String url

can't open file chooser in WebView Android 4.4.2 using WebChromeClient

£可爱£侵袭症+ 提交于 2019-12-01 07:16:31
In my webview by clicking "Choose File" button In samsung 7 inch tablet I want to open a File Browser, but I can't open this in Android Version 4.4.2 . So can u plz help me for this? Here is my Code. WebViewDemo.java package com.example.webviewdemo; import java.io.File; import android.app.Activity; import android.app.ProgressDialog; import android.content.Intent; import android.content.res.Configuration; import android.graphics.Bitmap; import android.net.Uri; import android.os.Bundle; import android.os.Environment; import android.os.Parcelable; import android.provider.MediaStore; import

How to detect errors only from the main page in new onReceivedError from WebViewClient

前提是你 提交于 2019-12-01 03:23:22
问题 Context In the Android SDK 23 onReceivedError(WebView view, int errorCode, String description, String failingUrl) has been deprecated and replaced with onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) . However as per documentation: Note that unlike the deprecated version of the callback, the new version will be called for any resource (iframe, image, etc), not just for the main page Problem We have an app where in the deprecated onReceivedError method there

WebView - can't download file without requesting it twice?

依然范特西╮ 提交于 2019-12-01 01:08:11
问题 If I listen with DownloadListener , I get the URL which I need to request after the browser already requested it . The browser already opened a connection to the URL (which is how it knows this is a download), why can't it pass me the connection? I also tried to assign a custom WebViewClient to the WebView and use shouldOverrideUrlLoading to catch URLs before they are requested. To download files that way, I request every URL before the browser and by it's Content-Type I decide whether to

can't open file chooser in WebView Android 4.4.2 using WebChromeClient

冷暖自知 提交于 2019-11-30 17:59:31
问题 In my webview by clicking "Choose File" button In samsung 7 inch tablet I want to open a File Browser, but I can't open this in Android Version 4.4.2 . So can u plz help me for this? Here is my Code. WebViewDemo.java package com.example.webviewdemo; import java.io.File; import android.app.Activity; import android.app.ProgressDialog; import android.content.Intent; import android.content.res.Configuration; import android.graphics.Bitmap; import android.net.Uri; import android.os.Bundle; import

Android WebView ignoring target=“_blank” when added WebViewClient

爱⌒轻易说出口 提交于 2019-11-30 13:18:13
I am facing a strange issue. In my application, I need to load a static html file based on clicked button in a WebView from assets folder. Now among 5 html files, one html file contains 15 static links. These links need to redirect user to the mentioned url in a mobile browser. I have used target="_blank" for that purpose as follows in my html file. <div class="lid"><a href="https://www.irctc.co.in/" target="_blank">Railway Reservation </a></div> Now, this works fine in a sample application with a simple WebView without any WebViewClient added to it. But I need a WebViewClient for my other

Android JS in WebView.loadUrl()

你说的曾经没有我的故事 提交于 2019-11-30 12:56:02
问题 I want to load a webpage in WebView but remove parts of the webpage. So, I created a custom WebViewClient. And, in onPageFinished(), I did some javascript to remove some elements. Then, I made the WebView visible. However, when I run it, it sets the view visible, and then I see the elements being removed. It is as if the JS is running in the background very slowly. It creates a poor viewing experience because it flashes the full page and then the desired partial page. Here is my

Android - Load PDF inside webview

拜拜、爱过 提交于 2019-11-30 05:31:58
I have this webview code and I want to make it possible to have the PDF files opened when a user clicks on a PDF link. Here is the code, can you tell me what I have to put inside the PDF area of this? I've tried many different ways and I cannot get the PDF to view at all. Thanks for the help. webview.setWebViewClient ( new WebViewClient() { public boolean shouldOverrideUrlLoading(WebView view, String url) { // do your handling codes here, which url is the requested url // probably you need to open that url rather than redirect: if (url.startsWith("tel:")) { startActivity(new Intent(Intent