public boolean isNetworkConnectionAvailable(){
ConnectivityManager manager = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetwork = manager.getActiveNetworkInfo();
boolean isConnected = activeNetwork != null && activeNetwork.isConnected();
if(isConnected) {
Log.d("Network", "Connected");
return true;
}
else{
checkNetworkConnection();
Log.d("Network","Not Connected");
return false;
}
}
這表明無法解決connectivitymanager和NETWORKINFO ....請幫助.. 在此先感謝檢查網絡連接在android中是否可用?
嘗試清潔工程後的重建..嘗試添加此直接 進口android.net .ConnectivityManager; import android.net.NetworkInfo; –
檢查您的清單是否具有適當的權限,您應該擁有「android.permission.ACCESS_NETWORK_STATE」權限。 – Dexter