title: Best way to check internet connection in whole app
body: <p>I want to check internet connection in whole app. I've googled for it, but the result was everyone creates an instance method in each class and tries to check the internet connection. My plan is to create a class with static method and check it without instantiating my class. <strong>Is it good idea to do that? Or should I try another way?</strong> My plan is to do something like this:</p>
  
  <pre><code>public class CheckInternetConnecting {
  
      public static boolean isOnline(Context context) {
           ConnectivityManager cm =
              (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
  
          return cm.getActiveNetworkInfo() != null &amp;&amp;
              cm.getActiveNetworkInfo().isConnectedOrConnecting();
      }
  }
  </code></pre>