制作一个临时 Activity .. 就像一个你好屏幕

Making a temporary Activity .. Like a hello screen

我想做一个临时的 Activity 让我可以展示它,例如它只出现 5 秒,那么我该怎么做呢 >> 就像我应用程序开头的问候屏幕.

顺便说一句,我正在使用 Android Studio

初始屏幕显示 2 秒,然后出现应用程序的主 activity。为此,我们添加了一个 java class 来显示启动画面。它使用线程等待 2 秒,然后使用意图启动下一个 activity。

public class SplashScreen extends Activity {
private long ms=0;
private long splashTime=2000;
private boolean splashActive = true;
private boolean paused=false;
 @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
Thread mythread = new Thread() {
public void run() {
   try {
      while (splashActive && ms < splashTime) {
         if(!paused)
         ms=ms+100;
         sleep(100);
       }
   } catch(Exception e) {}
     finally {
     Intent intent = new Intent(SplashScreen.this, Splash.class);
     startActivity(intent);
     }
   }
 };
   mythread.start();
}
}