您的位置:首页 > 移动开发

判断app是否是第一次进入

2016-04-23 17:44 477 查看
以前做的一个算是小项目的里面就有一个这样的设置,现在写也写不出来,还是把这个记录下来吧。

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

preferences = getSharedPreferences("count",MODE_WORLD_READABLE);
int count = preferences.getInt("count", 0);

//判断程序与第几次运行,如果是第一次运行则跳转到引导页面
if (count != 0) {
Intent intent = new Intent();
intent.setClass(getApplicationContext(),LaunchGuideViewActivity.class);
startActivity(intent);
this.finish();
}
Editor editor = preferences.edit();
//存入数据
editor.putInt("count", ++count);
//提交修改
editor.commit();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: