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. c't magazine on Android apps securit

The German computer magazine c't, one of Europe's largest computer
magazines, published an article on the security of various Android
(and iPhone) apps. Because the OS is as relevant as the apps
themselves, I wrote a mail to the editors to point out this issue. If
they print it, perhaps a wider public discussion will help resolve

I'm still hoping and waiting for an official answer. Google, are you
reading this?
I'm Cc'ing Rich Cannings, whom I believe to be part of the Android
security team. He posted the "Adroid security team introduction" to
full disclosure in 2008. Perhaps he can shed some light on why there
is no official reponse yet.



2. Broadcasting and receiving

My IntentService is happily chugging away and sends a broadcast of
results when it's done:


Meanwhile, my main thread has a receiver defined like this:

                       registerReceiver( myReceiver = new
BroadcastReceiver() {
                        public void onReceive(Context arg0, Intent theIntent ) {
                                // process the received data
                        } }
                        , new IntentFilter("mySpecialName") );

But the onReceive method is not getting the message. I'm guessing I
need to do something with "mySpecialName" in the manifest or some
such. Any pointers?


3. Fwd: Communicate with GSM modem

4. Communicate with GSM modem

5. IntentService instantiation exception

6. Canvas.drawBitmap while setting transparent a given color

7. Loading XML data to array 鈥済i ves up鈥?if XML is too big