public boolean checkInternet() {
ConnectivityManager connectivityManager = (ConnectivityManager)getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
if(networkInfo != null) {
if(networkInfo.isAvailable() && networkInfo.isConnected() || networkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
Toast.makeText(getApplicationContext(), "Available", Toast.LENGTH_SHORT).show();
return true;
} else {
Toast.makeText(getApplicationContext(), "Not Available", Toast.LENGTH_SHORT).show();
return false;
}
}
Toast.makeText(getApplicationContext(), "Not Available", Toast.LENGTH_SHORT).show();
return false;
}
Comments
Post a Comment