Android学習ノート---android簡単で効果的なフラッシュスクリーン制作

906 ワード

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        new Handler().postDelayed(new Runnable(){
			public void run() {
                Intent mainIntent = new Intent(SplashActivity.this,MainActivity.class); 
                SplashActivity.this.startActivity(mainIntent); 
                SplashActivity.this.finish(); 
			}}, 10000);
    }

 
APIにおけるHandlerに対するpostDelayed法は以下のように記述される.
Android APIは
final boolean postDelayed(Runnable r, long delayMillis) Causes the Runnable r to be added to the message queue, to be run after the specified amount of time elapses.
 
RunnableオブジェクトrをdeleyMillisの時間が経過した後、メッセージキューに追加します.つまり、どのくらい後に何をすればいいかを話します.簡単そうに見えますが、HTMLのsettimeoutやsetInternalの方法に似ていて、使うのも簡単です.