I have a class which extends Application class. In this class I am checking Internet Connectivity and calling the web service.
Below is the method I am using to check:
public static boolean isInternetConnected(Context mContext) {
ConnectivityManager connec = (ConnectivityManager) mContext
.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connec != null
&& (connec.getNetworkInfo(1).getState() == NetworkInfo.State.CONNECTED)
|| (connec.getNetworkInfo(0).getState() == NetworkInfo.State.CONNECTED)) {
return true;
}
return false;
}
When there is no Internet connection I want to force close the application. How to do it?
I have an alternative solution. If there is no Internet connection, I can skip calling api process and wait for the first activity to start and finish that activity as soon as it starts.
Is it possible to do it in Application class?