設備是否有3g /數據已激活。想知道發生了什麼? 謝謝檢查3G是否連接始終返回false(即使設備已連接)
我的代碼:
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;
}
你試過這段代碼嗎?它返回什麼? – androidnoob 2012-01-16 01:30:58