1. 程式人生 > >轉:Android檢查設備是否聯網

轉:Android檢查設備是否聯網

bool and roi systems lean oid div static andro

 1 public static boolean isConnect(Context context) {  
 2     ConnectivityManager connectionManager = (ConnectivityManager) context  
 3             .getSystemService(Context.CONNECTIVITY_SERVICE);  
 4     if (connectionManager != null) {  
 5         NetworkInfo info = connectionManager.getActiveNetworkInfo();  
6 if (info != null && info.isConnected()) { 7 if (info.getState() == NetworkInfo.State.CONNECTED) { 8 return true; 9 } 10 } 11 } 12 return false; 13 }

轉:Android檢查設備是否聯網