Application HANGS UP if 3G connection is used (WiFi is OK)
        Posted  
        
            by SkyEagle888
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by SkyEagle888
        
        
        
        Published on 2010-05-30T16:05:47Z
        Indexed on 
            2010/05/30
            16:12 UTC
        
        
        Read the original article
        Hit count: 207
        
android
|android-sdk
Hi,
My application uses the following codes to connect to web site and download a web page for processing.
HttpURLConnection c = (HttpURLConnection) url.openConnection();
c.setRequestMethod("GET");
c.setRequestProperty("User-Agent", "Mozilla/3.0 (compatible; MSIE 4.0; Windows NT)");
c.setRequestProperty("Accept-Language", "zh-hk");
c.setRequestProperty("Connection", "Keep-Alive");
c.setConnectTimeout(6000); // mTimeout is in seconds
intTries = 3;
do {
   c.connect();
   if (c.getResponseCode() == 200) {
      break;
   }
   else {
      intTries --;
   }       
} while (intTries > 0);
The codes are run in main thread only. If WiFi is being used, it is nice and clean. If 3G connection is being used, sometimes, it cannot get connected OR application HANGS.
Is there any significant difference between handling WiFi and 3G ?
Thanks.
© Stack Overflow or respective owner