引导页的实现

基础入门笔记

2014-05-15 08:56

开场 去掉标题栏

-------------------------------------------------------------------------------------------------------------------

requestWindowFeature(Window.FEATURE_NO_TITLE);

-----------------------------------------------------------------------------------------------------------------

然后 比较版本

------------------------------------------------------------------------------------------------------------------

//判断当前系统本版 和 当前要求版本

if(Build.VERSION_CODES.GINGERBREAD<8){

AlertDialog.Builder alertwin=new AlertDialog.Builder(Main.this);

alertwin.setTitle("系统提示");

alertwin.setMessage("杯具啊,你的系统版本太低了。无法运行这个程序.亲升级系统吧.");

alertwin.setNeutralButton("退出系统", new DialogInterface.OnClickListener() {

@Override

public void onClick(DialogInterface dialog, int which) {

finish();

       System.exit(0);

}});

AlertDialog atd=alertwin.create();

atd.show();

return ;

}

----------------------------------------------------------------------------------------------------------------

然后查看网络状态

-----------------------------------------------------------------------------------------------------------------

String net_state=network.get(Main.this);

boolean networkState = network.detect(Main.this);  

if (networkState)

{

Toast.makeText(getBaseContext(), "联网类型:"+net_state,3).show();

gotoup();

}

else

{

Toast.makeText(getBaseContext(), "没有联网",3).show();

AlertDialog.Builder alertwin=new AlertDialog.Builder(Main.this);

alertwin.setTitle("系统提示");

alertwin.setMessage("请检查你的联网状态");

//alertwin.setIcon(R.drawable.s5);

alertwin.setNeutralButton("设置WIFI", new DialogInterface.OnClickListener() {

@Override

public void onClick(DialogInterface dialog, int which) {

startActivity(new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS));

}});

alertwin.setNegativeButton("设置3G",new DialogInterface.OnClickListener() {

@Override

public void onClick(DialogInterface dialog, int which) {

startActivity(new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS));

}});

alertwin.setPositiveButton("跳过",new DialogInterface.OnClickListener() {

@Override

public void onClick(DialogInterface dialog, int which) {

toindex();

}});

AlertDialog atd=alertwin.create();

atd.show();

}

--------------------------------------------------------------------------------------------------------

如果网站状态正常联网 多线程传给主线程  返回的版本信息

---------------------------------------------------------------------------------------------------------

new Thread() 

{

public void run() 

{

String u="";

web_get w_g=new web_get();

u= w_g.getdata("http://221.180.149.73:8765/banben.php","1");

try { Thread.sleep(3000);} 

catch (Exception e) 

{ }

Message msg = new Message();

msg.what = TIME_UP;

msg.obj=u;

handler.sendMessage(msg);

}

}.start();

---------------------------------------------------------------------------------------------

根据返回信息

-----------------------------------------------------------------------------------------------

final UpdateManager mUpdateManager = new UpdateManager(Main.this);  

if(mUpdateManager.judge(msg.obj.toString())){//如果不是最新

     

AlertDialog.Builder alertwin=new AlertDialog.Builder(Main.this);

alertwin.setTitle("系统提示");

alertwin.setMessage("发现新版本"+mUpdateManager.Wversion+"是否更新?\n"+mUpdateManager.Wrq+"\n"+mUpdateManager.Wcn);

alertwin.setNeutralButton("更新", new DialogInterface.OnClickListener() {

@Override

public void onClick(DialogInterface dialog, int which) {

//更新操作

mUpdateManager.checkUpdateInfo();  //下载新的APK

}});

alertwin.setNegativeButton("稍后",new DialogInterface.OnClickListener() {

@Override

public void onClick(DialogInterface dialog, int which) {

//如果是放弃 进入主页

toindex();

}});

AlertDialog atd=alertwin.create();

atd.show();

}else{

//如果是最新 进入主页

toindex();

}