w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to catch connection lost error on open socket connection?
         public static boolean isNetworkAvailable(Context
context           ,DialogInterface.OnDismissListener dismissListener,
Boolean endActivity){

     ConnectivityManager conMgr =
(ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
 
     NetworkInfo info= conMgr.getActiveNetworkInfo();

     boolean isNetworkAvailable=false;
       if(info != null && info.isConnected()) { 
          isNetworkAvailable=true;
       //    Log.e("NetworkInfo","Connected State");  
       }  
       else{  
         isNetworkAvailable=false;
         alertNetworkConnection(context,dismissListener,endActivity);
     //  Log.e("NetworkInfo","Not Connected state");  
       }

     return isNetworkAvailable;
}




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.