android程序启动界面

一个很简单的例子:程序启动界面

 

主要code:

package com.ssx.startload;

 


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Window;
import android.view.WindowManager;

public class StartLoadActivity extends Activity {
 /** Called when the activity is first created. */
  public static final int CONTINUE = 0x108;
  public static final int UPDATE = 0x109;
  final Handler handler = new Handler() {
   @Override
   public void handleMessage(Message msg) {

    switch (msg.what) {
    case StartLoadActivity.CONTINUE:

     Intent it = new Intent();
     it.setClass(StartLoadActivity.this, MainActivity.class);
     startActivity(it);
     finish();
     break;
    }
    super.handleMessage(msg);
   }

  };

  @Override
  public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
     WindowManager.LayoutParams.FLAG_FULLSCREEN);
   requestWindowFeature(Window.FEATURE_NO_TITLE);
   setContentView(R.layout.start_loading);
   //handler.sendEmptyMessage(StartLoadingActivity.CONTINUE);
  Thread sleepThread = new Thread() {
    public void run() {

     try {
      Thread.sleep(5000);//设置启动欢迎界面时间
      Intent it = new Intent();
      it.setClass(StartLoadActivity.this, MainActivity.class);
      startActivity(it);
      handler.sendEmptyMessage(StartLoadActivity.CONTINUE);
     } catch (InterruptedException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      handler.sendEmptyMessage(StartLoadActivity.CONTINUE);
     }
    }
   };
   sleepThread.start();
  }
 }

 

你可能感兴趣的:(thread,android,OS)