title: Internet connection toast msg in android
body: <p>SplashScreenActivity.java</p>
  
  <pre><code>package com.example.wastewarriorsnew;
  
  
  public class SplashScreenActivity extends Activity {
  
   ConnectivityManager connectivityManager;
      NetworkInfo info;
  
   // Splash screen timer
   @Override
   protected void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     setContentView(R.layout.activity_splash_screen);
  
  
     Timer t = new Timer();
     boolean checkConnection=new SplashScreenActivity().checkConnection(this);
     if (checkConnection) {
         t.schedule(new splash(), 1000);
     } else {
         Toast.makeText(SplashScreenActivity.this,
                 "connection not found...plz check connection", 1000).show();
     }
    }
  
   class splash extends TimerTask {
  
     @Override
     public void run() {
         Intent i = new Intent(SplashScreenActivity.this,MainActivity.class);
         finish();
         startActivity(i);
     }
    }
  
  public boolean checkConnection(Context context) {
      // TODO Auto-generated method stub
       boolean flag = false;
          try {
              connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
              info = connectivityManager.getActiveNetworkInfo();
  
              if (info.getType() == ConnectivityManager.TYPE_WIFI) {
                  System.out.println(info.getTypeName());
                  flag = true;
              }
              if (info.getType() == ConnectivityManager.TYPE_MOBILE) {
                  System.out.println(info.getTypeName());
                  flag = true;
              }
          } catch (Exception exception) {
              System.out.println("Exception at network connection....."
                      + exception);
          }
          return flag;
  
      //return false;
   }
   }
  </code></pre>
  
  <p>Even after this,I am not getting the toast message,that internet connection is off.
  I dont understand what is wrong.
  Please help me to resolve it.
  I'm getting no errors,but without internet connection ,the app is running and displaying the main activity.
  When I click on save button,it unfortunately stops.</p>