//判断网络类型
try{
ConnectivityManager cm = (ConnectivityManager)this.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = cm.getActiveNetworkInfo();
if(info==null){
startActivity(new Intent(android.provider.Settings.ACTION_SETTINGS));
finish();
}else{
String typeName = info.getTypeName().toLowerCase(); // WIFI/MOBILE
if(typeName.equals("wifi")){
}else{
typeName=info.getExtraInfo().toLowerCase();
if("3gnet".equals(typeName)||"3gwap".equals(typeName)||"uniwap".equals(typeName)||"uninet".equals(typeName)){
}else{
new AlertDialog.Builder(ActivityLogin.this).setTitle("提示").setMessage("非联通用户无法登陆!").setNeutralButton("确定", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dlg, int sumthin) {
}
}).show();
return;
}
}
}
}catch(Exception e){
e.printStackTrace();
startActivity(new Intent(android.provider.Settings.ACTION_SETTINGS));
finish();
}