Device Disconnect auto

Put your problem here if it does not fit any of the other categories.

Device Disconnect auto

Postby mithat » Fri Feb 11, 2011 4:59 pm

Hi everybody !
Help me, my application connect to server. i use the following code:
Code: Select all
public class HttpConnections {

   private HttpURLConnection conn = null;
   private URL url = null;
//   public HttpConnection(HttpsURLConnection conn){
//      this.conn = conn;
//   }
   public HttpURLConnection setConnection(){
      try{
         Parameters.connected = true;
         url = new URL(Parameters.url);
      }catch(MalformedURLException e){
         Parameters.connected = false;
         e.printStackTrace();
         return conn;
      }
      if(url!=null){
         try{
            System.setProperty("http.keepAlive", "false");
            conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod("POST");
            conn.setRequestProperty("content-type", "text/plain; charset=utf-8");
            conn.setDoInput(true);
            conn.setDoOutput(true);
            conn.setUseCaches(false);
            Parameters.connected = true;
            conn.connect();
            
         }catch(IOException e){
            e.printStackTrace();
            Parameters.connected = false;
            System.out.println("Erorr connection!");
            return conn;
         }
      }
      return conn;
   }
   public void disconnection(HttpURLConnection conn){
      conn.disconnect();
   }
}


Normally, when the application is still connected and fine. But when the used application and device to switch to standby mode screen.After about 2 hours, i turned back application but receive message: application disconection. I'm on the internet via IE brower not to be. I use the 3G network.
Was it because the device manager or by code?. I reinstalled on the 3G network, connection back to normal. Expect people to help me. Thanks
mithat
Junior Developer
Junior Developer
 
Posts: 14
Joined: Thu Jul 29, 2010 5:05 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 16 guests