import android.content.Intent
;
import android.content.SharedPreferences
;
import android.os.Bundle
;
import android.support.v7.app.AppCompatActivity
;
import android.view.animation.Animation
;
import android.view.animation.AnimationUtils
;
import android.widget.ImageView
;
public class MainActivity
extends AppCompatActivity {
private ImageView
imageView;
private SharedPreferences.Editor
edit;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState)
;
setContentView(R.layout.
activity_main)
;
imageView = (ImageView) findViewById(R.id.
imageview)
;
//记录进入过此界面,下次进入直接跳转
SharedPreferences sharedperfers = getSharedPreferences(
"ssss", MODE_PRIVATE)
;
edit = sharedperfers.edit()
;
boolean ame = sharedperfers.getBoolean(
"name", true)
;
if (ame==
false) {
Intent intent =
new Intent(MainActivity.
this, SecondActivity.
class)
;
startActivity(intent)
;
finish()
;
}
else {
// 开启动画。
Animation rotate = AnimationUtils.
loadAnimation(
this, R.anim.
aaa)
;
imageView.startAnimation(rotate)
;
// 设置动画监听
rotate.setAnimationListener(
new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
// 设置动画结束时的监听
@Override
public void onAnimationEnd(Animation animation) {
// 设置存储 布尔类型 为true
edit.putBoolean(
"name", false)
;
edit.commit()
;
Intent intent =
new Intent(MainActivity.
this, SecondActivity.
class)
;
startActivity(intent)
;
finish()
;
}
@Override
public void onAnimationRepeat(Animation animation) {
}
})
;
}
}
}
转载请注明原文地址: https://ju.6miu.com/read-25248.html