android应用开发:第一次打开app时是欢迎页,推出之后每次再打开都直接进入主页面,如何设计app的页面关系

Android 码拜 9年前 (2015-05-10) 1646次浏览 0个评论
 

android应用开发:第一次打开app时是欢迎页,推出之后每次再打开都直接进入主页面,如何设计app的页面关系

5分
在欢迎界面判断一下,如果不是第一次启动,就跳转到主界面。是的话,不跳转。
怎么判断呢?求示例!谢谢
怎么判断呢?求示例!谢谢
可以利用各种存储来判断是否第一次启动,比如sp,比如xml
5分
笨点就写个一个文件上,聪明点就用个SharedPreferences
10分
正好我的应用里面有这个,就分享给你了:在mainfest中guide页<action android:name=”android.intent.action.MAIN” />

guide页面:
       

private SharedPreferences sharepreferences;
	private SharedPreferences.Editor editor;
       ....
       oncreat()
      sharepreferences=this.getSharedPreferences("check", MODE_PRIVATE);
			editor=sharepreferences.edit();
	        
	        boolean fristload=sharepreferences.getBoolean("fristload", true);

      if (!fristload) {
				Intent intent = new Intent();
				intent.setClass(this,toActivity.class);
				startActivityForResult(intent,0);
			}
     button.setOnClickListener(new OnClickListener() {
				public void onClick(View v) {

					editor.putBoolean("fristload", false);

					Intent intent = new Intent();
				        intent.setClass(this,toActivity.class);

					startActivityForResult(intent, 0);

				       }
				}
			});
5854符合国家和国家
引用 6 楼 lulong1985 的回复:

正好我的应用里面有这个,就分享给你了:在mainfest中guide页<action android:name=”android.intent.action.MAIN” />

guide页面:
       

private SharedPreferences sharepreferences;
	private SharedPreferences.Editor editor;
       ....
       oncreat()
      sharepreferences=this.getSharedPreferences("check", MODE_PRIVATE);
			editor=sharepreferences.edit();
	        
	        boolean fristload=sharepreferences.getBoolean("fristload", true);

      if (!fristload) {
				Intent intent = new Intent();
				intent.setClass(this,toActivity.class);
				startActivityForResult(intent,0);
			}
     button.setOnClickListener(new OnClickListener() {
				public void onClick(View v) {

					editor.putBoolean("fristload", false);

					Intent intent = new Intent();
				        intent.setClass(this,toActivity.class);

					startActivityForResult(intent, 0);

				       }
				}
			});

这种方法在安装新版本应用是不是会删除fristload值的,所以安装新版本的时候还是不会进入到第一次启动的界面

直接用sharepreferences存版本号,然后判断大小就好的。
引用 8 楼 qiantujava 的回复:
Quote: 引用 6 楼 lulong1985 的回复:

正好我的应用里面有这个,就分享给你了:在mainfest中guide页<action android:name=”android.intent.action.MAIN” />

guide页面:
       

private SharedPreferences sharepreferences;
	private SharedPreferences.Editor editor;
       ....
       oncreat()
      sharepreferences=this.getSharedPreferences("check", MODE_PRIVATE);
			editor=sharepreferences.edit();
	        
	        boolean fristload=sharepreferences.getBoolean("fristload", true);

      if (!fristload) {
				Intent intent = new Intent();
				intent.setClass(this,toActivity.class);
				startActivityForResult(intent,0);
			}
     button.setOnClickListener(new OnClickListener() {
				public void onClick(View v) {

					editor.putBoolean("fristload", false);

					Intent intent = new Intent();
				        intent.setClass(this,toActivity.class);

					startActivityForResult(intent, 0);

				       }
				}
			});

这种方法在安装新版本应用是不是会删除fristload值的,所以安装新版本的时候还是不会进入到第一次启动的界面

你没有editor.commit();


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明android应用开发:第一次打开app时是欢迎页,推出之后每次再打开都直接进入主页面,如何设计app的页面关系
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!