internet connection - Android: Force close the app in Application class -


I have a class that increases the application class. In this class I am checking Internet connectivity and calling the web service.

The method I am using below is to check:

  The public static bullion is the Internet connect (reference macantax) {connectivity manager contacts = (connectivity) Manager) mContext .getSystemService (reference. CONNECTIVITY_SERVICE); If (connection! = Null & amp; (connec.getNetworkInfo (1) .getState () == NetworkInfo.State.CONNECTED) || (connec.getNetworkInfo (0) .getState () == NetworkInfo.State.CONNECTED)) {Back true; } return false; }   

When there is no internet connection, I want to close the application. How to do this

I have an alternative solution if there is no internet connection, I can skip the API process and wait for the first activity to start and as soon as it starts it I can end the activity.

Is it possible to do this in the application class?

Why do you want to close an application?

When there is no internet, you can turn off such activity:

  if (! Internet connect (reference)) {end (); }    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -