android-webview

Prevent data from loading using shouldInterceptRequest

扶醉桌前 提交于 2020-01-01 14:55:30
问题 While this has been asked several times, the only question that really relates to my issue is this (Can I use shouldInterceptRequest to block a particular call in Android?), but it was asked more than 3 years ago and eventually got no replies. The request I'm trying to block is a POST request, so the shouldOverrideUrlLoading method is unable to intercept it. After a button is clicked, the webview loads an URL that contains the following string: "androidBundleId_********". I need to block this

How to print a WebView?

我只是一个虾纸丫 提交于 2020-01-01 14:39:12
问题 My Android app renders a WebView containing a canvas. Cloud Print wants a PDF. How can I generate a PDF with my WebView to send to Cloud Print? 回答1: You could first capture the canvas as a png: (taken from stackoverflow answer) var canvas = document.getElementById("mycanvas"); var img = canvas.toDataURL("image/png"); Then next step get this into a pdf. I haven't seen a javascript based converter, but one could send the png to a custom web service (perhaps running on Google Apps, Amazon AWS or

How to print a WebView?

江枫思渺然 提交于 2020-01-01 14:38:00
问题 My Android app renders a WebView containing a canvas. Cloud Print wants a PDF. How can I generate a PDF with my WebView to send to Cloud Print? 回答1: You could first capture the canvas as a png: (taken from stackoverflow answer) var canvas = document.getElementById("mycanvas"); var img = canvas.toDataURL("image/png"); Then next step get this into a pdf. I haven't seen a javascript based converter, but one could send the png to a custom web service (perhaps running on Google Apps, Amazon AWS or

Why isn't my WebView filling up the entire width of my screen?

北战南征 提交于 2020-01-01 10:44:29
问题 My WebView doesn't fill the entire width of my phone. I am telling to fill_parent. Not sure why? <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal"> <WebView android:layout_height="fill_parent" android:layout_width="fill_parent" android:id="@+id/WebView"></WebView> </LinearLayout> 回答1: The linear layout is orientation horizontal I

WebView returns bad window.innerHeight

Deadly 提交于 2020-01-01 04:30:16
问题 I have an application that makes use of the Android WebView, as well as some JavaScript. When my WebViewClient calls onPageFinished() , I alert my JavaScript to run an initializing method. My JavaScript is enabled and loaded before I hit onPageFinished() . In that JavaScript method I make use of window.innerWidth . However, the value it returns is always wrong and always the same. Regardless of my orientation it reports that the inner width is 320, and the inner height is 240. (Correct width

Can the PostMessage API be used to communicate with an Android WebView?

左心房为你撑大大i 提交于 2020-01-01 03:58:06
问题 I usually use the HTML5 PostMessage API to communicate information from my iframed content to the parent frame. Recently I've had my content used inside an Android WebView (as far as I can tell this is the native-Android equivalent of an iframe). Is there a way for the native app to listen for PostMessage events that I send up to them? I'm aware that addJavascriptInterface exists, I'm just hoping that there's a way to reuse my existing PostMessage code without writing something new. 回答1: I

Is it possible to access the WebView cache?

 ̄綄美尐妖づ 提交于 2020-01-01 03:24:13
问题 I have a WebView in which I can access to web pages. Is it possible, when I am offline to have access for example to the images that have been previously downloaded? And if it is possible how can I do this? Thanks in advance. 回答1: Yes, you can, at least for Android 2.3 and lower. If you want to see the entire cache folder, it is situated here: <android cache dir>/<your app package>/cache/webviewCache/ If you already know the URL of the cached image, you can get the actual file so: String uri

WebView java.lang.SecurityException: No permission to modify given thread

无人久伴 提交于 2020-01-01 02:10:09
问题 I have an application that uses multiple WebViews. Nowhere do I set the priority of the render thread through the WebSettings though I still get the exception below. So far it only seems to happen on android 4.0.4, which I haven't found the source code for. Anyone run into this and/or knows a solution? Thanks! java.lang.SecurityException: No permission to modify given thread at android.os.Process.setThreadPriority(Native Method) at android.webkit.WebViewCore$WebCoreThread$1.handleMessage

Variety of issues testing Android Webview using Appium

左心房为你撑大大i 提交于 2019-12-31 07:01:14
问题 I have a hybrid app that is primarily just a webview. Here is the code for the basic test: @BeforeClass public static void setupAppium() throws MalformedURLException { DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("appium-version", "1.5.3"); capabilities.setCapability("platformName", "Android"); capabilities.setCapability("platformVersion", "6.0"); capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "AppiumTesterDevice"); capabilities

Display pdf in webview of android

安稳与你 提交于 2019-12-31 05:06:05
问题 I'm displaying a pdf in webview using help of google docs, with this url , https://docs.google.com/gview?url=+location of pdf . It's breaking the pages and giving navigation icons on top right. Is there any way to display all the pages in single flow instead of breaking them. In the image above, instead of showing in 10 different pages, i want the pdf to be displayed in single flow, I don't want to use navigation buttons on top right. when &overridemobile=true is appended to URL , this image