I had this problem as well. I solved it by looping until I got a 200
response. It's 100% effective.

Here's is the relevant code:

http_response_code = -1 ;
HttpURLConnection conn = null ;
int iRetry = 0;
while ( iRetry < 10 ) {
        iRetry++ ;
        try {
                conn= (HttpURLConnection)myFileUrl.openConnection();
                conn.setConnectTimeout (30000) ;
                conn.setDoInput(true);
                conn.connect();
                http_response_code = conn.getResponseCode() ;
        } catch (IOException e) {
                e.printStackTrace();
                http_response_code = -1 ;
        }
        // Status code HttpURLConnection.HTTP_OK == 200...
                if (http_response_code == HttpURLConnection.HTTP_OK ) {
                iRetry = 10 ;
        }
}

-John Coryat

"What Zip Code?"

"Radar Now!"
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to