App前言

public class WelActivity extends Activity{

private SharedPreferences.Editor editor;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.wel_activity);

//设置动画

ImageView imageView = (ImageView) findViewById(R.id.imageView);

TranslateAnimation ta = (TranslateAnimation) AnimationUtils.loadAnimation(this, R.anim.image_anim);

imageView.setAnimation(ta);

//动画监听

ta.setAnimationListener(new Animation.AnimationListener() {

@Override

public void onAnimationStart(Animation animation) {

}

@Override

public void onAnimationEnd(Animation animation) {

//跳转到主界面

Intent intent = new Intent(WelActivity.this, MainActivity.class);

startActivity(intent);

finish();

editor.putBoolean("flag",true);

editor.commit();

}

@Override

public void onAnimationRepeat(Animation animation) {

}

});

//sharedPreferences存值

SharedPreferences preferences = getSharedPreferences("config", MODE_PRIVATE);

editor = preferences.edit();

Boolean flag= preferences.getBoolean("flag",false);

if(flag){

Intent intent =new Intent(WelActivity.this,MainActivity.class);

startActivity(intent);

finish();

}else{

editor.putBoolean("flag",true);

editor.commit();

}

}

}

你可能感兴趣的:(App前言)