webviewclient

Open PDF in a WebView

。_饼干妹妹 提交于 2019-12-28 02:39:05
问题 I want to open a PDF in my WebView, and I found and combined codes on this forum. But it catches the "No PDF application found" although I have multiple PDF apps installed, including Adobe Reader. Here the code: private class PsvWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); if (url.contains(".pdf")) { Uri path = Uri.parse(url); Intent pdfIntent = new Intent(Intent.ACTION_VIEW); pdfIntent.setDataAndType

Web View not working with some specific url

ぐ巨炮叔叔 提交于 2019-12-24 15:33:05
问题 public class MainActivity extends AppCompatActivity { String url = "https://www.pinterest.com"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); WebView webView = findViewById(R.id.webview); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setLoadWithOverviewMode(true); webView.getSettings().setUseWideViewPort(true); webView.setWebViewClient(new WebViewClient(){ @Override public

Android - Webviewclient onReceivedHttpError determine if is main resource

被刻印的时光 ゝ 提交于 2019-12-24 09:58:45
问题 WebViewClient.onReceivedError was deprecated, now I have to use onReceivedHttpError to handle the webview errors, however this method receives the error from any resource, which is not what I desire. I wish only to detect the main URL failing . How should I detect the error if I am using API 10 ? I tried using the request.getUrl() method but it is only compatible with API 23. 回答1: Meanwhile, I ended up doing this: @Override public void onReceivedError(WebView view, int errorCode, String

Listen for URL fragment id change in WebView

房东的猫 提交于 2019-12-23 14:52:13
问题 It seems that the WebViewClient methods such as shouldInterceptRequest(), onPageStarted(), and shouldOverrideUrlLoading() only listen for URL changes that cause the WebView to load a new page. Is there a way to detect URL changes for fragment IDs, i.e. index.html#fragment_id, on a WebView? 回答1: I know that this is a really old question but i found out a solution that isn't available anywhere in Stack Overflow. jpetitto's answer works but it messes up javascript if we use hash change for

Show Progress using ProgressBar for WebViewClient

╄→гoц情女王★ 提交于 2019-12-23 05:37:12
问题 I am using WebViewClient to load web pages and I would like to show progress bar for my code. My code isn't loading the progress gradually. It only shows 100% progress. How do I set the progress based on web page loading time? For my purpose I have to load just "https://www.google.com" on a WebView only. Please help. Thank you. Code is shown below : Activity file public class MainActivity extends Activity { private WebView webView; private ProgressBar progressBar; @Override protected void

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

空扰寡人 提交于 2019-12-20 09:56:22
问题 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 .

Upload camera photo and filechooser from webview INPUT field

十年热恋 提交于 2019-12-18 11:43:04
问题 My app is webbased and I need to upload pictures from an INPUT field camp. I've two situations and as i don't know another way to do it depending the page I'm choosing one or another with "boolean boolFileChoser" depending its URL petition: a. file picker b. camera photo shoot. I've dealt with file picker and it upload the file perfectly, the problem is with the camera. Once i try to upload the Camera Pic, it crashes. As far as i know its because the URI. a) File picker: content://media

How do I use DownloadListener?

橙三吉。 提交于 2019-12-17 19:47:07
问题 I am creating an app that allows college students to download their study material from within the app instead of the browser. The home page has lots of subject names. Each subject name leads to new webpage. So, I have used WebViewClient . But, at the final page when I click on the *.ppt or *.pdf files it opens junk. I want these files to be downloaded within the app. How do I implement DownloadListener package jiit.app; import android.app.Activity; import android.os.Bundle; import android

Are WebViewClient and WebChromeClient mutually exclusive?

风格不统一 提交于 2019-12-17 17:28:44
问题 From this great explanation about the differences between WebViewClient and WebChromeClient it seems that if you use one, you shouldn't be using the other (for the same WebView object). Is my understanding correct? If not, when would one use both WebViewClient and WebChromeClient for the same WebView object? Is there an example of a situation where only use both WebViewClient and WebChromeClient for the same WebView object would accomplish a certain goal? 回答1: You certainly can use both, they

Looking for Android ViewFlipper Example with Multiple WebViews

℡╲_俬逩灬. 提交于 2019-12-17 15:35:15
问题 As I am sure you all know. Setting up a WebView is a matter of creating a webview browser client, setting properties and loading a resource into the browser client. I have created several android apps that do exactly that. What i would like to try now is horizontal swiping of different web resources. Imagine a main home page at one url, a categories page at another url and a search page at another url. I would like to create a UI construct that allows swiping from the main home page url view