Why does this not draw the layout first, then sleep?
It does show the next activity correctly after sleeping, but before sleeping does not show the first screen. This is intended to be a splash screen.
In order, it should:
– Set the content view ( show the splash )
– Create the thread.
– Run the thread
– Thread sleeps
– Thread starts the new activity.
Only, it appears it’s not happening like that. Any help is much appreciated
package nutterzUK.spinDroid.application;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class SpinDroidActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Thread myThread = new Thread(){
public void run(){
try {
Intent myIntent = new Intent(SpinDroidActivity.this, NextActivity.class);
this.sleep(5000);
startActivity(myIntent);
finish();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
};
myThread.run();
}
}
In fact you aren’t creating a concurrent situation. You are executing the
run()method in the UI thread.The call you want to do is
which launches the Thread concurrently.