check connection available or not in android.

public static boolean isNetworkAvailable(Context cont) {
   ConnectivityManager connectivityManager
         = (ConnectivityManager)cont. getSystemService(Context.CONNECTIVITY_SERVICE);
   NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
   return activeNetworkInfo != null && activeNetworkInfo.isConnected();
}




and check this in-

if(isNetworkAvailable(getApplicationContext()))
{
new Resiter().execute();
}
else
{
Toast.makeText(getApplicationContext(), "Internet Unavailable...Please connect to Internet",3000).show(); }

Popular posts from this blog

Simple Sign up design. Android.

Cart page design in android.

Set Date on jDateChooser and retrieve record from database.