title: Using a Thread.sleep() for delaying not executing some part of code in java
body: <p>I am new to Android. I'm trying to develop a calculator, which has a home view(activity) which is displayed as soon as the app is launched for a while and then calculator starts as a new activity. In order to wait a while in home screen I am using <code>Thread.sleep()</code> as shown in code below.</p>
  
  <pre><code> protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.first);
      TextView loading = (TextView) findViewById(R.id.loading);
      loading.setText("Loading...");
      try {
          Thread.sleep(20000);
      } catch (InterruptedException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  
      startActivity(new Intent(MainActivity.this, second.class));
  }
  </code></pre>
  
  <p>The problem is that <code>loading.setText("Loading...")</code> is not writing anything to <code>TextView</code> until 20 sec if put <code>startActivity()</code> in comments.</p>