title: android app shows blank screen (not updating ui) while in a loop
body: <p>In my application, a client is connected to server.  It waits until the connection to the server occurs.  During that time the application is not responding.  How can i solve this problem.  Tried code snippet shows below</p>
  
  <pre><code>public Connection(){
      client.SetParent(this);
      this.context = g.getContext();
      bConnected = false;
  
      mNetworkRunner = new Runnable() {
          public void run() {
              try {
                  Log.e("", "mNetworkRunner...");
  
                  if( SendKeepAlive()){
                      Main.conStatus(1);
                      Log.e("", "SendKeepAlive...");
                  }
                  else {
                      Main.conStatus(0);
                      Log.e("", "No connection...");
  
                      g.log("Connection to server is lost... Trying to Connect...");
                      while(true){
                          Log.e("", "In while loop...");
  
                          if(!Connect()){
                              g.log("Trying...");
                              Log.e("", "In Connect no connect...");
                              Thread.sleep(2000);
                          }
                          else {
                              g.log("Connected");
                              break;
                          }
  
                      }
                      Main.conStatus(1);
                  }
                  mNetworkHandler.postDelayed(this, 30000);
              }
              catch (Exception e) {
                  e.printStackTrace();
              }
          }
      };      
  
  }
  // 
  private void CheckNetworkConnection(){
      if( mNetworkHandler == null ){
          mNetworkHandler = new Handler();
          mNetworkHandler.post(mNetworkRunner);
          Log.e("", "CheckNetworkConnection...");
      }       
  }
  </code></pre>