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 }  

 

相关文章:

  • 2021-12-11
  • 2022-12-23
  • 2021-09-25
  • 2021-09-10
  • 2022-12-23
  • 2021-09-17
猜你喜欢
  • 2022-12-23
  • 2021-11-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-25
相关资源
相似解决方案