As Tushar answered above, inheriting from something like InternetActivity
is fine, but you should not check it in onResume
unless you are using some service which constantly requires internet connection. Instead, check it when an event like a button click occurs to go to next activity; so without starting another activity, you can display a toast to check internet connection. You should do this for any event that requires internet because whole activity rarely requires continuous internet connection.
You can add this method in that super class:
private boolean isInternetConnected() {
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
return cm.getActiveNetworkInfo() != null
&& cm.getActiveNetworkInfo().isConnectedOrConnecting();
}
Then:
if(isInternetConnected())
//to the internet thing
else
//display toast