public class MainActivity extends AppCompatActivity { int i=3; Handler handler=new Handler(){ @Override public void handleMessage(Message msg) { if (i<0){ i--; handler.sendEmptyMessageDelayed(0,1000); }else{
//跳转 Intent intent=new Intent(MainActivity.this,Main2Activity.class); startActivity(intent); finish(); } } }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //发送消息 handler.sendEmptyMessageDelayed(0,1000); } }