title: How to set ContentView to Another Fragment if No internet is available and Resume Fragment if Connection is Available
body: <p>After my App Login, I need to check Internet Connection before every <code>onClick</code> event and after every <code>Fragment</code> is added or replaced.If Internet Connection is not Available the <code>setContentView</code> should set another Fragment and as soon as the Internet get Available it should set the working fragment.<br>
  This is code for checking <code>NetworkStatus</code> </p>
  
  <pre><code>public class NetworkStatus {
      public static String checkConnection(Context context){
  
          ConnectivityManager connectivitymanager=(ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
  
  
          if(connectivitymanager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState()==NetworkInfo.State.CONNECTED || connectivitymanager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState()==NetworkInfo.State.CONNECTED){
  
              return "true";
  
          }else{
              return "false";
          }
      }  
  </code></pre>
  
  <p>This is code before performing any <code>onClick</code> event  </p>
  
  <pre><code>String NetworkStatus=NetworkStatus.checkConnection(getContext());
          if(NetworkStatus.equals("false"))
          {
              alert.noInternetAlert(getActivity());
          }
          else
          {
              performAction();
          }  
  </code></pre>
  
  <p>Now How to <code>setContentView</code> to different Fragment if no connection is available while replacing and adding new Fragments and resume to Fragment if connection get Available ? </p>