当前位置: 代码迷 >> Android >> 今天碰到个有关问题 不得不让小弟我说华为+电信定制机垃圾
  详细解决方案

今天碰到个有关问题 不得不让小弟我说华为+电信定制机垃圾

热度:84   发布时间:2016-05-01 17:51:35.0
今天碰到个问题 不得不让我说华为+电信定制机垃圾
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权限都没办法破解,只能给华为发个解锁申请单才能解锁。真恶心华为和电信的定制机

------解决方案--------------------
如果是会报错的话可以用try/catch来包一下,毕竟不是每台机都有这样的问题没必要为了一颗小树强迫整个森林都要改变
------解决方案--------------------
定制机和普通手机到底有些什么不同啊?
------解决方案--------------------
对于实现来说,谁规定了必须是在
"com.android.settings",
"com.android.settings.WirelessSettings"
了呢?
他改的很多,把包名改成自己公司的呢!

手机厂商实现API,3rd party按照API来调用。
  相关解决方案