所以...我开发了一个成功运行的启动画面。我怎样才能让它运行一次(并且只运行一次)?我想建立一个注册屏幕,但我只希望它为用户显示一次。
帮助!
阿曼尼·斯旺
import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.content.Intent;
import com.nfc.linkingmanager.R;
public class SplashScreen extends Activity {
private boolean mIsBackButtonPressed;
private static final int SPLASH_DURATION = 1000;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash_screen);
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
finish();
if (!mIsBackButtonPressed) {
Intent intent = new Intent(SplashScreen.this, NewCore.class);
SplashScreen.this.startActivity(intent);
}
}
}, SPLASH_DURATION);
}
@Override
public void onBackPressed() {
mIsBackButtonPressed = true;
super.onBackPressed();
}
}