You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
package com.example.musicwork ;
import androidx.appcompat.app.AppCompatActivity ;
import android.os.Bundle ;
import android.content.Intent ;
import android.os.Handler ;
import android.view.KeyEvent ;
public class StartActivity extends AppCompatActivity {
private Handler handler = new Handler ( ) ;
@Override
protected void onCreate ( Bundle savedInstanceState ) {
super . onCreate ( savedInstanceState ) ;
// 注意: 此处将setContentView()方法注释掉
// setContentView(R.layout.activity_start);
handler . postDelayed ( new Runnable ( ) {
@Override
public void run ( ) {
gotoLogin ( ) ;
}
} , 1500 ) ;
}
/**
* 前往注册、登录主页
*/
private void gotoLogin ( ) {
Intent intent = new Intent ( StartActivity . this , SignIn . class ) ;
startActivity ( intent ) ;
finish ( ) ;
//取消界面跳转时的动画, 使启动页的logo图片与注册、登录主页的logo图片完美衔接
overridePendingTransition ( 0 , 0 ) ;
}
/**
* 屏蔽物理返回键
*/
@Override
public boolean onKeyDown ( int keyCode , KeyEvent event ) {
if ( keyCode = = KeyEvent . KEYCODE_BACK ) {
return true ;
}
return super . onKeyDown ( keyCode , event ) ;
}
@Override
protected void onDestroy ( ) {
if ( handler ! = null ) {
//If token is null, all callbacks and messages will be removed.
handler . removeCallbacksAndMessages ( null ) ;
}
super . onDestroy ( ) ;
}
}