【发布时间】:2012-01-24 07:37:05
【问题描述】:
我正在尝试让我的应用程序启动一个启动屏幕 5 秒,同时在后台初始化各种 Web 服务。这是我的代码:
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Splash screen view
setContentView(R.layout.splashscreen);
final SplashScreen sPlashScreen = this;
// The thread to wait for splash screen events
mSplashThread = new Thread()
{
@Override
public void run()
{
try {
synchronized(this){
// Wait given period of time or exit on touch
wait(5000);
}
}
catch(InterruptedException ex)
{
}
finally
{
finish();
// Run next activity
Intent intent = new Intent();
intent.setClass(sPlashScreen, Splash_testActivity.class);
startActivity(intent);
stop();
}
}
};
mSplashThread.start();
for (int i=0;i<100;i++)
Log.d("splash test", "initialize web methods");
}
现在我认为应该发生的是,在显示初始屏幕时,应用程序应该记录“初始化 Web 方法”。
但实际发生的是,只有斜杠消失后才添加日志。
我做错了什么??
【问题讨论】:
标签: java android multithreading splash-screen