Q:

How to show toast at Splash Screen

im working on an android application in which i have a main activity and Activity_splash.xml
which is my splash screen activity. what i want is when my app is launched, and if there is internet connection, the splash screen should appear for 3 seconds and after that main activity should launch and if there is No internet turned on, then it should show "No internet connection " toast and open wireless networks settings and after enabling wifi, if return button is pressed, user should be brought back to splash screen... hope this is understandable.. but my code is not working as im getting bunch of errors which are
1.ACTION_WIRELESS_SETTINGS cannot be resolved or is not a field.
2.syntax error on token "{",{ expected after this token (in line public class SplashScreen       extends Activity {)
3.syntax error on token "(",; expected and syntax error on token ")",; expected (in line  protected void onCreate(Bundle savedInstanceState) {)
SplashScreen.java
public class SplashScreen extends Activity {
if (!NetworkCheckClass.haveNetworkConnection(SplashActivity.this)) {
    Toast.makeText(SplashScreen.this, "No internet connection!",             Toast.LENGTH_LONG).show();

    Intent intent=new Intent(Settings.ACTION_WIRELESS_SETTINGS);
    startActivity(intent);
}
else {
    // your code if connection is available
} // Splash screen timer
    private static int SPLASH_TIME_OUT = 3000;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);

        new Handler().postDelayed(new Runnable() {

            /*
             * Showing splash screen with a timer. This will be useful when you
             * want to show case your app logo / company
             */

            @Override
            public void run() {
                // This method will be executed once the timer is over
                // Start your app main activity
                Intent i = new Intent(SplashScreen.this, MainActivity.class);
                startActivity(i);

                // close this activity
                finish();
            }
        }, SPLASH_TIME_OUT);
    }
  }
  }

A:

Write below code in OnCreate() of your activity :
if (!NetworkCheckClass.haveNetworkConnection(SplashActivity.this)) {
Toast.makeText(SplashScreen.this, "No internet connection!",             Toast.LENGTH_LONG).show();

Intent intent=new Intent(Settings.ACTION_WIRELESS_SETTINGS);
startActivity(intent);
}
else {
 // your code if connection is available
} // Splash screen timer

