public static boolean isNetworkAvailable( Context context) {
ConnectivityManager connectivity = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivity == null) {
System.out.println("**** newwork is off");
return false;
} else {
NetworkInfo info = connectivity.getActiveNetworkInfo();
if(info == null){
System.out.println("**** newwork is off");
return false;
}else{
if(info.isAvailable()){
System.out.println("**** newwork is on");
return true;
}
}
}
System.out.println("**** newwork is off");
return false;
}
ConnectivityManager connectivity = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivity == null) {
System.out.println("**** newwork is off");
return false;
} else {
NetworkInfo info = connectivity.getActiveNetworkInfo();
if(info == null){
System.out.println("**** newwork is off");
return false;
}else{
if(info.isAvailable()){
System.out.println("**** newwork is on");
return true;
}
}
}
System.out.println("**** newwork is off");
return false;
}