设备是否激活了3g/数据。知道发生了什么吗?谢谢
我的代码:
public boolean isConnected3G(){
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo[] networks = cm.getAllNetworkInfo();
for (NetworkInfo ni : networks)
if ("MOBILE".equalsIgnoreCase(ni.getTypeName())){
Log.d(TAG,""+ni.isConnected());
if (ni.isConnected())
return true;
}
return false;
}
尝试使用NetworkInfo ni=cm.getActiveNetworkInfo()而不是cm.getAllNetworkInfo(;并检查网络信息