title: Should I check connectivity in every activity in Android?
body: <p>So I just implemented a checking connectivity method, but should I do this for every activity?  Is there a simpler way to continually check for connectivity?</p>
  
  <pre><code>public static boolean isNetworkAvailable(Context context) {
  
      ConnectivityManager cm =
              (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
  
      NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
  
      boolean isConnected = activeNetwork != null &amp;&amp;
              activeNetwork.isConnectedOrConnecting();
  
      return isConnected;
  }
  </code></pre>