After upgrading to Android 4.0 ‘Ice Cream Sandwich‘ I found that some of my existing apps weren’t working as expected.
On deeper investigation I discovered the culprit. When installed on devices running ICS the apps made HTTP POST requests when they were programmed to be GET requests.
It appears that Google have subtly changed the working of the java.net.HttpURLConnection class – without telling anyone!
The Android package reference documentation has this little gem tucked away in the class overview notes:
HTTP Methods
HttpURLConnection
uses theGET
method by default. It will usePOST
ifsetDoOutput(true)
has been called. Other HTTP methods (OPTIONS
,HEAD
,PUT
,DELETE
andTRACE
) can be used withsetRequestMethod(String)
.
My now non-functional Android apps did indeed call setDoOutput, but in Android releases prior to 4.0 this did not result in the HTTP method being changed from a GET to a POST.
Even explicitly setting setRequestMethod("GET")
does not fix the problem. Basically if you don’t want your app to POST, you must not call setDoOutput
.
The apps have not changed, there is nothing referencing this change in the API Differences Report, but the behaviour is definitely different in Android 4.0.
Could this be what’s behind the flurry of Android Market app updates for ICS-related fixes?
I just purchased the Samsung Galaxy Nexus from Verizon and was hoping to use the Picasa Mobile slideshow capability. It does show all the photos but I need to go through one-by-one. Are you going to have an upgrade soon?
Thank you.
Jorge Gardos
jgardos523@gmail.com
I don’t understand why you think that your problem with the Picasa Mobile app has anything to do with me.
I suggest you take it up with the developer, which according to Android Market would appear to be imprologic@gmail.com
For the avoidance of doubt, me != Google.
Thanks. The same problem we had with our ChinesePod Android app. Solved now.