public static boolean isNetworkAvailable(Context act) {
ConnectivityManager connectivityManager
= (ConnectivityManager) act.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
return activeNetworkInfo != null;
}
if(isNetworkAvailable(MainActivity.this)
{
//connection avilable
}
else{
//no connection
}
ConnectivityManager connectivityManager
= (ConnectivityManager) act.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
return activeNetworkInfo != null;
}
if(isNetworkAvailable(MainActivity.this)
{
//connection avilable
}
else{
//no connection
}
No comments:
Post a Comment