Android 代码判断是否有网络
public void okGo() { ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo(); if (networkInfo != null && networkInfo.isAvailable()) { Toast.makeText(RadarActivity.this, "当前网络可用", Toast.LENGTH_SHORT).show(); } else { Toast.makeText(RadarActivity.this, "当前网络不可用", Toast.LENGTH_SHORT).show(); } }
努力不是表现给谁看的,而是从小白渐渐走向牛X的过程!!!