0

This is my SplashActivity and what I have to do to quit my app if there is no internet connection I want to check both the wifi and mobile data and display a toast message and quit?

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

    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            Intent intent = new Intent(SplashActivity.this, MainActivity.class);
            startActivity(intent);
            finish();

        }
    },3500);

}

}
Doe
  • 1
  • 1
  • Check this link to read about AppStatus and in your main change the If to close the app when you get that the device dont have internet connection. [AppStatus Tutorial To Close App Withouth Connection](https://androidstudy.com/2017/04/17/android-detect-internet-connection-status/) – GonzaloPani Aug 01 '18 at 12:19
  • what you want? here you want to check wifi r mobile data available or want to check if connected to google.com – Revathi Manoharan Aug 01 '18 at 12:23
  • @RevathiManoharan I want to check both the connection and if there is no internet connectivity I want the app to be force closed. – Doe Aug 01 '18 at 12:25
  • use broadcast listener and please follow this link https://stackoverflow.com/questions/25678216/android-internet-connectivity-change-listener .... i using this.i hope its helpfull to u.. when u use broadcast listener dont forget to register and unregister broadcast service.@Doe – Revathi Manoharan Aug 01 '18 at 12:32

0 Answers0