Android中设置只有程序第一次运行才显示的界面实现思路
程序安装后第一次启动:
启动页-->功能介绍页-->系统主页
以后启动:
启动页-->系统主页
所以在启动页中判断一下就可以了
可以弄一个文件保存一个状态,推荐用sharedpreferences。
1.可以定义一个变量来判断程序是第几次运行,如果是第一次则跳转到引导的activity,如果不是第一次则执行系统主页。
判断系统是第一次运行的代码实现如下:
在activity中添加代码:
使用sharedpreferences来记录程序的使用次数
一下是实现的代码:
<span style="font-size: 18px"><strong>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();</strong></span>
如对本文有疑问,
点击进行留言回复!!
相关文章:
-
-
-
-
-
-
Binder(2)
1.binder_initdevice_initcall(binder_init); static int __...
[阅读全文]
-
-
-
-
-
网友评论