The Phonegap documentation indicates that it is possible to get the app's browser wrapper to load a custom error URL instead of showing a generic message should the application encounter an error. I find myself asking two questions here:
From what I can tell this is an Android-only feature. So is there an equivalent method for iOS? The Phonegap iOS documentation does not say anything on the subject.
Secondly, can the error URL point to a separate HTML document in the project/www folder from which the application will be built or does it have to be an external URL. My thinking is that an external URL does not in fact make much sense - what if the application error happens when the user is not on a network?
I'd be most obliged to anyone who might be able to calriify these issues.
From OP
From what I can tell this is an Android-only feature. So is there an equivalent method for iOS? The Phonegap iOS documentation does not say anything on the subject.
There appears to be no equivalent for iOS in the documentation. You can safely assume, if it is not there, it is not available.
To be clear, the underlying iOS library has no default error method. On Android, there is a method for dealing with this.
Secondly, can the error URL point to a separate HTML document in the project/www folder from which the application will be built or does it have to be an external URL. My thinking is that an external URL does not in fact make much sense - what if the application error happens when the user is not on a network?
Your assumption is correct. The "error.html" should be on the device and in the www/ directory. The file should NOT be on the network/internet. You'd be surprised how many times I see this error.
Related
I thought this would be a common issue but I can't find an straight-forward answer to this problem. As soon as I included the Crosswalk WebView Engine for Android I'm getting the following Error Message:
"Only secure origins are allowed"
.... Presumably for http requests made to local and external servers (like http://localhost:3000 or https://my.own.server/) using the angular $http service.
What is THE Solution to this issue? After many hours of Googling I'm still clueless about how to solve this issue. Could you please point me in the right direction?
kind regards,
EDIT: This question is not related to permissions given in a server as it has been pointed out, it's actually related to Content Security Policy. As it can be read here, and I quote:
Controls which network requests (images, XHRs, etc) are allowed to be made (via webview directly).
You have to understand that the WebView in this case is Crosswalk (which is Chromium underneath) and I need it to be configured so that I can make requests to both: local servers (http://localhost:3000, etc) and external ones (https://my.own.server).
This question is more akin to this one in my opinion.
How do I configure Crosswalk for an Ionic/Cordova app?
If you own the server then the easiest way to handle this is to add response header for:
Access-Control-Allow-Origin: *
Here are some a discussion in Stackoverflow itself.
Origin is not allowed by Access-Control-Allow-Origin
Good luck.
The title says it all. I would like to know about everything what the WebView is asking for. Some weird limitations like not knowing about XHR POST are not acceptable. In other words, something like iOS have in NSURLProtocol. That one is application-wide hook. I don't need such level of control, WebView-instance-specific hook would be good enough. Now, i know that nothing like that exists on Android out of the box. I know about shouldOverrideUrlLoading and shouldInterceptRequest, but it's largely unusable. I need to know about requests (method, HTTP version, headers, you know) not just merely the URL strings. Moreover the intercepting is awkwardly synchronous. What happens if shouldInterceptRequest call is blocked because i need to ask a different server for related resource? It appears to me being designed just for a local resource caching.
On the other hand, i am willing to throw anything at the problem. Some kind of native library, hooking into low level internals? Extending Chromium interfaces with help of an existing project (pwnall, mogoweb)? Reflecting into the existing webkit class privates? Application-specific proxy? Any insights appreciated. I have read through two dozens of existing SO questions. They all either suggest a partial hack (like working around XHR POST deficiency with JavaScript) or it goes unresponded altogether, very often.
Try with inspeckage:
https://github.com/ac-pm/Inspeckage
It needs Xposed and root access to work. I've been able to see WebView requests from apps. Im figuring out how to recreate them with Python's requests module.
Hope that helps.
If I understand your goal - try:
WebView.setWebContentsDebuggingEnabled(true);
Open Chrome and go to url chrome://inspect/#devices
for details:
https://developers.google.com/web/tools/chrome-devtools/remote-debugging
https://developers.google.com/web/tools/chrome-devtools/remote-debugging/webviews
I have a very simple HTML5 app written with trigger.io that fails running under Android 4.4 with errors stating that local content cannot be accessed. Example:
E/AndroidProtocolHandler( 2236): Unable to open content URL: content:////io.trigger.forge9aee7db8338b11e4b77d1231392b77b0/src/images/connect4.jpg
The same code works find under Android 4.3. This applies to all local content including images, CSS and JavaScript. All resources are referenced with relative paths such as "images/image.jpg".
My best guess is that there is an access policy change in newer versions of Android OS but I cannot figure out the details. I have made sure that nowhere in the code attempts to access external resources.
Antoine van Gelder was incredibly helpful on this. His diagnosis was absolutely correct that jQuery Mobile is rewriting the URLs for resources which causes newer versions of Android's Chrome Webview to fail when accessing resources. The generated URLs contain quadruple slashes after the protocol like this:
content:////io.trigger.forge9aee7db8338b11e4b77d1231392b77b0/src/resource.png
The extra slashes cause Webview to fail. Possibly some excessive checking for correctness or a security implication?
Antoine's suggestions of using older versions of jQuery Mobile or building a custom jQuery Mobile without Base Tag will probably work in some circumstances though neither was quite sufficient in my case. Particularly, removing Base Tag also removes some other functionality I needed.
An alternative approach is to make a minor hack to jQuery Mobile. For version 1.4.3 I did the following:
Edited an un-minified version of jQuery Mobile's javascript
Modified the getLocation function:
Save the return value to a temporary variable
Modify the temporary variable by removing quadruple slashes.
I used something very specific and restricted to the "content" protocol: "retVal = retVal.replace("content:////","content://");"
Return the fixed temporary variable
It looks like, starting with v1.3, jQuery Mobile are rewriting the URL's in your document which breaks the Chrome Webview's access to files in the app sandbox.
You could try filing a bug report with the jQuery Mobile devs but to sort this out in the short term your best options are probably one of:
1) Fall back to jQuery Mobile 1.2.1
2) Build a custom version of jQuery Mobile which excludes some navigation features. (Go to download builder (http://jquerymobile.com/download-builder/), scroll down to "Navigation" and de-select the "Base Tag" module)
This should be fixed in JqueryMobile 1.4.4.
(re-post from the PG google group)
I know there's been a lot of conversation on this in the past, but I've been researching it for the past few days and couldn't seem to find a definitive answer (or even what it would entail).
I was wondering how plausible it would be to embed a snapshot build of the Chrome webview (or even the Gecko webview) into a Phonegap app and to use that in place of the native webview that PhoneGap uses. The problem is twofold - 1) Android's native browser/webview is terrible and 2) Each phone seems to have idiosyncratic bugs/differences, which having one set snapshot to build against would fix.
I've seen answers ranging from "Oh, yeah, just build the source and drop it in" to "You'd need a full team of Java devs to hack the PhoneGap API core to get it to work". Does anyone have an answer of what it would entail, how much time it would take, if it's even plausible, etc? I suppose the biggest concern is - given we can get a snapshot build of the Chrome webview, does that break any of the connections to the PhoneGap APIs? Are they tied specifically to the native webview?
Any and all thoughts are appreciated. Thanks!
Chrome has the ability to be embedded by use of the Content Module. In theory (I have never done it) you can build this and embed it into your Application and use that instead of a WebView - it has the advantage of being an up to date Chrome and multi-process. It loses value in that it can't be used pre-Jellybean.
I'm developing an Android application using C++ and Qt Necessitas SDK.
My application should load/save files and I want to handle it using Android actions ( so that I can target Google Drive as well as Dropbox etc... )
The question is... how do I raise Intents ( and which Intent should I raise to share/import my files ) from C++ ?
Rationale: how do I load and save files ( either custom mimetype, or pdf ) using Qt Necessitas on Android?
I'm a complete newbie to java and I know nothing of JNI, but apparently this link will explain how to [use the JNI to] use intents in your QT for Android applications: http://community.kde.org/Necessitas/JNI
It looks pretty straightforward, but I'm afraid I don't yet understand what I'm reading enough to give you a better answer to your question.
Sources:
groups.google.com/forum/?fromgroups=#!topic/android-qt/U3eHis9mLrg
groups.google.com/forum/?fromgroups=#!topic/android-qt/UpgBRz8Imwo
Another option for a some things (opening websites, making phone calls, possibly opening local PDFs and images) would apparently be QDesktopServices::OpenURL() - although that seems to give open-only access (ie, opening the resource but not pulling any data back from it).
I'm interested in this so that I can use the barcode scanner app "ZXING", which has an intent-as-url at http://zxing.appspot.com/scan - I don't know what other little secrets are out there...
HTH until someone can give you a better answer
(2 links disabled due to insufficient reputation)