今天碰到个问题 不得不让我说华为+电信定制机垃圾
private boolean NetWorkStatus(Context con) {
// boolean netSataus = false;
ConnectivityManager cwjManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
if (cwjManager == null)
return false;
NetworkInfo netinfo = cwjManager.getActiveNetworkInfo();
if(netinfo != null){
return netinfo.isAvailable();
}
// if(netinfo.isConnected()){
// return true;
// }
// cwjManager.getActiveNetworkInfo();
//
// if (cwjManager.getActiveNetworkInfo() != null) {
// netSataus = cwjManager.getActiveNetworkInfo().isConnected();
// }
if (netinfo ==null ) {
Builder b = new AlertDialog.Builder(this).setTitle("没有可用的网络")
.setMessage("是否对网络进行设置?");
b.setPositiveButton("是", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
Intent mIntent = new Intent("/");
ComponentName comp = new ComponentName(
"com.android.settings",
"com.android.settings.WirelessSettings");
mIntent.setComponent(comp);
mIntent.setAction("android.intent.action.VIEW");
startActivityForResult(mIntent,0);
}
}).setNeutralButton("否", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dialog.cancel();
}
}).show();
return true;
}
return true;
}
代码 主要的用途不用我说了吧 大家都能看懂 就是在无网络的时候哦 提示用户是否打开网络
公司的手机都是华为+电信的那个C8812机型的。让我很无语。这段代码在别的机器上一点问题都没有 在定制机上 没有网络的时候打开配置界面直接就报错 这段机型连ROOT权限都没办法破解,只能给华为发个解锁申请单才能解锁。真恶心华为和电信的定制机