//////Check Internet Connection return True or False ///////
public static boolean isInternetAvailable(Context context)
{
boolean isInetrnetAvailable = false;
try
{
ConnectivityManager connectivityManager = (ConnectivityManager)
context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
if(networkInfo != null)
{
if( networkInfo.isConnected())
{
isInetrnetAvailable = true;
}
else
{
isInetrnetAvailable = false;
}
}
else
{
isInetrnetAvailable = false;
}
}
catch(Exception exception)
{
isInetrnetAvailable = false;
}
return isInetrnetAvailable;
}
------------------------------------------
in addition you can navigate the user to Wireless and Network settings through calling ....
startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS));
public static boolean isInternetAvailable(Context context)
{
boolean isInetrnetAvailable = false;
try
{
ConnectivityManager connectivityManager = (ConnectivityManager)
context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
if(networkInfo != null)
{
if( networkInfo.isConnected())
{
isInetrnetAvailable = true;
}
else
{
isInetrnetAvailable = false;
}
}
else
{
isInetrnetAvailable = false;
}
}
catch(Exception exception)
{
isInetrnetAvailable = false;
}
return isInetrnetAvailable;
}
------------------------------------------
in addition you can navigate the user to Wireless and Network settings through calling ....
startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS));
No comments:
Post a Comment