In one of my classes, I call WebView.postUrl():
getWebView().postUrl(url, EncodingUtils.getBytes(postData, "BASE64"));
Which works perfectly on an LG Optimus S, but doesn’t work for some reason on an HTC Nexus One.
By “works” I mean that the target site responds to the postUrl() query with the expected results and is characterized by always:
- generating two
WebViewClient.onPageStarted()calls, - followed by a
WebView.loadUrl()and - followed by a
WebViewClient.onPageFinished()
On the culprit Nexus One, however, only the first WebViewClient.onPageStarted() call is generated, never followed by any other call.
Obviously WebView and/or WebViewClient are behaving differently on the different devices, because both devices run the same exact application code.
(or is it the website that’s responding differently to the different devices, which use the same exact WiFi gateway?)
Both devices run the same exact application code, but the Android versions are slightly different: The LG runs 2.3.3 and the N1 runs 2.2.1.
Any idea or tips on how to approach the debugging of this tough problem?
For example, are there any hooks that I can place somewhere to trace what’s really going on under the cover?
Override onReceivedSslError and onReceivedError of your WebViewClient. I’m guessing it is an issue with 2.2 not trusting certain CAs, or a bug that causes problems wildcard domains in SSL certificates – both of these specific errors will be caught in onReceivedSslError.
If either of these methods gets called, the page might not get finished loading.
If there aren’t any errors, your server might be doing something different because of the device’s User-Agent – which you might have to manually set.