HttpConnection Intermittent Poblems

by Ryan » Fri, 06 Mar 2009 02:22:32 GMT

Sponsored Links

My app uses a simple HttpConnection to download and parse some XML
that I host. The important code is as follows:-

                URL url = new URL(urlStr);
                URLConnection connection = url.openConnection();
                HttpURLConnection httpConnection = (HttpURLConnection)
                int responseCode = httpConnection.getResponseCode();

                if(responseCode == HttpURLConnection.HTTP_OK) {
                        // do useful stuff here
                else {
                                               // display connection
failed error message here

This works all the time on my G1 (based in UK), but a number of my
users are complaing they always see the connection failed message.
This is even though they have 3G connections and can browse the
internet, use google maps etc.

Can you see that I'm doing something obviously wrong?

Is there a more robust way to connect?

Any advice greatly appreciated,



Other Threads

1. how to run adb shell on windows as super user

Root your phone, perhaps? I'm only guessing; I haven't rooted a device

If com.lam.recipedisplay is your own app, you could probably add code
to copy the database to/from an alternate location such as /sdcard.

If it's not your app, well... this is why you're not given a root
shell by default ;)


2. Animation fillAfter(true) and click locations

I'm sure there's a purpose for fillAfter(true), but I have not found it.

If you want the effects of the animation to be permanent, you need to
add a listener to the animation, find out when the animation ends, and
then take steps to make the changes that the animation simulates.

So, for example, if you are sliding a button off of the screen, when the
animation ends, you could make the visibility of that button be GONE, or
remove it from its parent container, or something.

Mark Murphy (a Commons Guy) |

Android Consulting/App Development:


3. new android service

4. Using services synchronously

5. Apps2sd terminal

6. Ask Jualan

7. Why is English the only Locale my Phone has in Settings