title: How to check currently internet connection is available or not in android
body: <p>I want to execute my application offline also, so I need to check if currently an internet connection is available or not. Can anybody tell me how to check if internet is available or not in android? Give sample code. I tried with the code below and checked using an emulator but it's not working</p>
  
  <pre><code>public  boolean isInternetConnection() 
  { 
  
      ConnectivityManager connectivityManager =  (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
      return connectivityManager.getActiveNetworkInfo().isConnectedOrConnecting(); 
  } 
  </code></pre>
  
  <p>Thanks</p>