【发布时间】:2012-06-15 15:01:56
【问题描述】:
我有一个显示启动画面的应用。初始屏幕活动创建一个新的 Runnable,它只是休眠 1 秒,然后启动主要活动:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
UKMPGDataProvider.init(this.getApplicationContext(), Constants.DATABASE_NAME);
Thread splashThread = new Thread() {
@Override
public void run() {
try {
sleep(ONE_SECOND_IN_MILLIS);
} catch (InterruptedException e) {
} finally {
Intent intent = new Intent(SplashScreen.this, MainScreen.class);
finish();
startActivity(intent);
}
}
};
splashThread.start();
}
是否可以在这个新线程上启动主要活动(以及因此除了启动屏幕之外的整个应用程序)?
我们听到了很多关于 Android 中的“UI 线程”的信息。这个新线程现在会成为 UI 线程,还是 UI 线程在某些方面特殊?
【问题讨论】:
标签: android multithreading android-activity