Follow up: taking out setDoOutput(true) makes it work for www.google.com as well.
http://stackoverflow.com/questions/8587913/what-exactly-does-urlconnection-setdooutput-affect The link above explains that setDoOutput(true) forces an HTTP POST request. So maybe it's just that the Google search server responds to to POST requests with a 404 unless they contain all proper search parameters (as they do when you actually use search)? -- Kostya 10 января 2012 г. 1:22 пользователь Kostya Vasilyev <[email protected]>написал: > I don't have the answer, but tried out your code on a Galaxy Nexus and got > the same exception. > > Amazingly enough, it works with "http://www.apple.com" and " > http://www.microsoft.com" :) > > So I'd say, go ahead a file a bug. > > -- Kostya > > 10 января 2012 г. 1:04 пользователь Aaron <[email protected]> написал: > > I have a couple of apps on Market that seem to be having issues >> related to Ice Cream Sandwich. >> >> The following code snippet will throw a FileNotFoundException on both >> the Android Emulator and the the Samsung Nexus: >> URL url = new URL ("http://www.google.com"); >> URLConnection connection = url.openConnection(); >> connection.setDoOutput(true); >> byte[] bytes = new byte[1024]; >> InputStream is = connection.getInputStream(); >> >> Here is the stack trace that is logged: >> D/AddNewTitleActivity(12424): java.io.FileNotFoundException: >> http://www.google.com >> D/AddNewTitleActivity(12424): at >> >> libcore.net.http.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java: >> 177) >> D/AddNewTitleActivity(12424): at >> >> com.flyingspheres.android.inventory.network.NetworkManager.callService(NetworkManager.java: >> 130) >> D/AddNewTitleActivity(12424): at >> >> com.flyingspheres.android.inventory.network.NetworkManager.retrieveHtmlContent(NetworkManager.java: >> 299) >> D/AddNewTitleActivity(12424): at >> com.flyingspheres.android.inventory.activities.add.AddNewTitleActivity >> $3$3$1.doInBackground(AddNewTitleActivity.java:336) >> D/AddNewTitleActivity(12424): at >> com.flyingspheres.android.inventory.activities.add.AddNewTitleActivity >> $3$3$1.doInBackground(AddNewTitleActivity.java:1) >> D/AddNewTitleActivity(12424): at android.os.AsyncTask >> $2.call(AsyncTask.java:264) >> D/AddNewTitleActivity(12424): at java.util.concurrent.FutureTask >> $Sync.innerRun(FutureTask.java:305) >> D/AddNewTitleActivity(12424): at >> java.util.concurrent.FutureTask.run(FutureTask.java:137) >> D/AddNewTitleActivity(12424): at >> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java: >> 1076) >> D/AddNewTitleActivity(12424): at >> java.util.concurrent.ThreadPoolExecutor >> $Worker.run(ThreadPoolExecutor.java:569) >> D/AddNewTitleActivity(12424): at java.lang.Thread.run(Thread.java: >> 856) >> >> There is a pretty easy work around by using the >> org.apache.http.client.HttpClient but the HttpURLConnection method >> works in all versions of android, >> with the except Ice Cream Sandwich. This is a breaking change that >> gives users a bad experience when upgrading their phone or >> experiencing apps for the first time, >> if they're coming from a different platform. >> >> Is this a known issue intended to force app developers to use a >> specific API or should I log this as a bug report? >> >> Thanks, >> >> -Aaron >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Android Developers" group. >> To post to this group, send email to [email protected] >> To unsubscribe from this group, send email to >> [email protected] >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en > > > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

