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

zxciop110 2012-07-13 05:38:29
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权限都没办法破解,只能给华为发个解锁申请单才能解锁。真恶心华为和电信的定制机
...全文
220 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
ant_qingyun27sc 2012-07-14
  • 打赏
  • 举报
回复
定制机和普通手机到底有些什么不同啊?
thl789 2012-07-14
  • 打赏
  • 举报
回复
对于实现来说,谁规定了必须是在
"com.android.settings",
"com.android.settings.WirelessSettings"
了呢?
他改的很多,把包名改成自己公司的呢!

手机厂商实现API,3rd party按照API来调用。
a383028663 2012-07-13
  • 打赏
  • 举报
回复
如果是会报错的话可以用try/catch来包一下,毕竟不是每台机都有这样的问题没必要为了一颗小树强迫整个森林都要改变
zxciop110 2012-07-13
  • 打赏
  • 举报
回复
官方文档
http://developer.android.com/reference/android/provider/Settings.html
用这个方法就OK了
zxciop110 2012-07-13
  • 打赏
  • 举报
回复
解决了 两个方法

startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS));//进入无线网络配置界面
//startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS)); //进入手机中的wifi网络设置界面
但很不友好 定死只能这样打开
zxciop110 2012-07-13
  • 打赏
  • 举报
回复
SDK是4.0的 在别4.0机器上没问题

80,337

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧