title: My first login attempt it doesnt give me any message
body: <p>The first attempt to login, whether the login info is correct or not, i get no response back, when its supposed to say either "Incorrect User ID / Password" or "Login Successful! ". But any time after the first attempt it prints the correct message, why is it doing this?</p>
  
  <pre><code>    public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
      requestWindowFeature(Window.FEATURE_NO_TITLE);
  
      setContentView(R.layout.activity_main);
      un = (EditText) findViewById(R.id.et_un);
      pw = (EditText) findViewById(R.id.et_pw);
      ok = (Button) findViewById(R.id.btn_login);
  //  error = (TextView) findViewById(R.id.tv_error);
      textview = (TextView) findViewById(R.id.textView1);
  
      ok.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              /**
               * According with the new StrictGuard policy, running long tasks
               * on the Main UI thread is not possible So creating new thread
               * to create and execute http operations
               */
              new Thread(new Runnable() {
                  @Override
                  public void run() {
                      ArrayList&lt;NameValuePair&gt; postParameters = new ArrayList&lt;NameValuePair&gt;();
                      postParameters.add(new BasicNameValuePair("UserID",
                              un.getText().toString()));
                      postParameters.add(new BasicNameValuePair("Password",
                              pw.getText().toString()));
  
                      String response = null;
                      try {
                          response = SimpleHttpClient
                                  .executeHttpPost("website",
                                          postParameters);
                           res = response.toString();
  
                          resp = res.replaceAll("\\s+", "");
                          System.out.println(res);
  
  
                      } catch (Exception e) {
                          e.printStackTrace();
                          errorMsg = e.getMessage();
                      }
                  }
              }).start();
              try {
                  Thread.sleep(1000);
  
                  /**
                   * Inside the new thread we cannot update the main thread So
                   * updating the main thread outside the new thread
                   */
  
                  //error.setText(resp);
                  if(res.indexOf("&lt;TITLE&gt;LoginOk&lt;/TITLE&gt;") != -1  ||(resp.indexOf("&lt;TITLE&gt;Login&lt;/TITLE&gt;") != -1)) {                   
                      textview.setText("Incorrect User ID / Password");
  
  
                  }
                  else if(res.indexOf("Already") != -1){
  
                  textview.setText("An account is already logged In");
                  }
                  else{
                  textview.setText("Login Successful! ");
                  }
                  if (null != errorMsg &amp;&amp; !errorMsg.isEmpty()) {
                      textview.setText(errorMsg);
                  }
              } catch (Exception e) {
                  textview.setText(e.getMessage());
              }
          }
      });
  }
  </code></pre>