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 Thread.sleep()
as shown in code below.
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));
}
The problem is that loading.setText("Loading...")
is not writing anything to TextView
until 20 sec if put startActivity()
in comments.