可以使用Android SplashScreen API来为非手机设备(如电视)创建启动屏幕。要实现这一点,需要按以下步骤操作:
创建一个drawable资源文件,在此资源文件中放置启动屏幕的图像,例如splash_background.xml。
在AndroidManifest.xml文件中为SplashScreen主题创建一个Activity:
注意:SplashActivity是你创建的Activity类的名称。
public class SplashActivity extends AppCompatActivity { private static int SPLASH_TIME_OUT = 3000;
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_splash);
new Handler().postDelayed(new Runnable() {
/*
* Showing splash screen with a timer. This will be useful when you
* want to show case your app logo / company
*/
@Override
public void run() {
// This method will be executed once the timer is over
// Start your app main activity
Intent i = new Intent(SplashActivity.this, MainActivity.class);
startActivity(i);
// close this activity
finish();
}
}, SPLASH_TIME_OUT);
} }
完成以上步骤后,就可以在非手机设备(如电视)上实现启动屏幕了
下一篇:AndroidSQLCursor