title: Check internet connectvity Android
body: <p>i am trying bellow code</p>
  
  <pre><code>ConnectivityManager conMgr = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
  if (conMgr.getActiveNetworkInfo() == null
  &amp;&amp; !conMgr.getActiveNetworkInfo().isConnected()
  &amp;&amp; !conMgr.getActiveNetworkInfo().isAvailable())
  </code></pre>
  
  <p>how ever it causes the app to crash</p>
  
  <p>when i use </p>
  
  <pre><code>if (conMgr.getActiveNetworkInfo() == null)
  </code></pre>
  
  <p>every thing works fine </p>
  
  <p>what is proper way to use </p>
  
  <pre><code>conMgr.getActiveNetworkInfo().isConnected()
  conMgr.getActiveNetworkInfo().isAvailable())
  </code></pre>
  
  <p>the ! is causing issues???</p>