title: No Internet Connection , not showing , android webview
body: <p>Below is my code. Android studio isn't showing any error, but when I run the app with no connection, it doesn't displays my message..</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
      List item
  
      DrawerLayout drawerLayout;
      ActionBarDrawerToggle drawerToggle;
      NavigationView navigation;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          initInstances();
  
          WebView myWebView = (WebView) findViewById(R.id.webView1);
          myWebView.getSettings().setJavaScriptEnabled(true);
  
  
          WebSettings webSettings = myWebView.getSettings();
          webSettings.setJavaScriptEnabled(true);
          myWebView.setWebViewClient(new WebViewClient());
          Context context = this;
          ConnectivityManager cm =
              (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
  
          NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
          boolean isConnected = activeNetwork != null &amp;&amp;
              activeNetwork.isConnectedOrConnecting();
          if(isConnected) {
              myWebView.loadUrl("http://alokitojhalakati.com");
          } else {
              Toast toast = Toast.makeText(MainActivity.this, "No Internet Connection", Toast.LENGTH_LONG);
              toast.show();
          }
      }
  
      private void initInstances() {
          getSupportActionBar().setHomeButtonEnabled(true);
          getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  
          drawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
          drawerToggle = new ActionBarDrawerToggle(MainActivity.this, drawerLayout, R.string.hello_world, R.string.hello_world);
          drawerLayout.setDrawerListener(drawerToggle);
  
          navigation = (NavigationView) findViewById(R.id.navigation_view);
          navigation.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
              @Override
              public boolean onNavigationItemSelected(MenuItem menuItem) {
                  int id = menuItem.getItemId();
                  switch (id) {
                      case R.id.navigation_item_1:
                          startActivity(new Intent(MainActivity.this,MainActivity.class));
                          break;
                      case R.id.navigation_item_2:
                          startActivity(new Intent(MainActivity.this,NationalActivity.class));
                          break;
                      case R.id.navigation_item_3:
                          startActivity(new Intent(MainActivity.this,Jhalakati.class));
                          break;
                      case R.id.navigation_item_4:
                          startActivity(new Intent(MainActivity.this,RajapurActivity.class));
                          break;
                      case R.id.navigation_item_5:
                          startActivity(new Intent(MainActivity.this,NolcityActivity.class));
                          break;
                      case R.id.navigation_item_6:
                          startActivity(new Intent(MainActivity.this,KathaliaActivity.class));
                          break;
                      case R.id.navigation_item_7:
                          startActivity(new Intent(MainActivity.this,SaradeshActivity.class));
                          break;
                      case R.id.navigation_item_8:
                          startActivity(new Intent(MainActivity.this,EconomicsActivity.class));
                          break;
                      case R.id.navigation_item_9:
                          startActivity(new Intent(MainActivity.this,SportsActivity.class));
                      break;
                  case R.id.navigation_item_10:
                      startActivity(new Intent(MainActivity.this,EntertainmentActivity.class));
                          break;
                      case R.id.navigation_item_11:
                          startActivity(new Intent(MainActivity.this,ITActivity.class));
                          break;
                      case R.id.navigation_item_12:
                          startActivity(new Intent(MainActivity.this,PrideofJActivity.class));
                          break;
                      case R.id.navigation_item_13:
                          startActivity(new Intent(MainActivity.this,ReligionActivity.class));
                          break;
                      case R.id.navigation_item_14:
                          startActivity(new Intent(MainActivity.this,MoreActivity.class));
                          break;
                      case R.id.navigation_item_15:
                          startActivity(new Intent(MainActivity.this,LogInActivity.class));
                          break;
                  }
                  return false;
              }
          });
      }
  
      @Override
      public void onPostCreate(Bundle savedInstanceState) {
          super.onPostCreate(savedInstanceState);
          drawerToggle.syncState();
      }
  
      @Override
      public void onConfigurationChanged(Configuration newConfig) {
          super.onConfigurationChanged(newConfig);
          drawerToggle.onConfigurationChanged(newConfig);
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          getMenuInflater().inflate(R.menu.menu_main, menu);
          return true;
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          if (drawerToggle.onOptionsItemSelected(item))
              return true;
          int id = item.getItemId();
  
          if (id == R.id.action_settings) {
              return true;
          }
          return super.onOptionsItemSelected(item);
      }
  }
  </code></pre>
  
  <p>XML</p>
  
  <pre><code>&lt;android.support.v4.widget.DrawerLayout 
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      android:id="@+id/drawerLayout"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;android.support.design.widget.CoordinatorLayout
          android:id="@+id/coordinator_layout"
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
  
          &lt;WebView
              android:id="@+id/webView1"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"/&gt;
  
      &lt;/android.support.design.widget.CoordinatorLayout&gt;
  
      &lt;android.support.design.widget.NavigationView
          android:id="@+id/navigation_view"
          android:layout_width="wrap_content"
          android:layout_height="match_parent"
          android:layout_gravity="start"
          app:itemIconTint="#d20b0d"
          app:itemTextColor="#333"
          app:menu="@menu/navigation_items" /&gt;
  &lt;/android.support.v4.widget.DrawerLayout&gt;
  </code></pre>
  
  <p>What's wrong here? What do I need to do to show a toast message when there is no connection?</p>