我正在开发一个 android 应用程序,当它加载应用程序时,我只有一个黑屏(直到应用程序站稳脚跟)。当 Emulator/Android Mobile 上出现黑屏时,我想显示全屏图像。查看其他应用程序,他们有一个公司徽标或弹出几秒钟的酷图片,有人可以告诉我该怎么做吗?
我使用这段代码:
public class SplashScreen extends Activity {
/**
* The thread to process splash screen events
*/
private Thread mSplashThread;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Splash screen view
setContentView(R.layout.activity_splash_screen);
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(3000);
}
}
catch(InterruptedException ex){
}
finish();
// Run next activity
Intent intent = new Intent();
intent.setClass(sPlashScreen, HomePage.class);
startActivity(intent);
}
};
mSplashThread.start();
}
/**
* Processes splash screen touch events
*/
@Override
public boolean onTouchEvent(MotionEvent evt) {
if(evt.getAction() == MotionEvent.ACTION_DOWN) {
synchronized(mSplashThread){
mSplashThread.notifyAll();
}
}
return true;
}
}