use this solution code your app not crash:
public boolean checkInternetConnectionALL() {
ConnectivityManager conmag = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = conmag.getActiveNetworkInfo();
if (info != null && info.isConnected())
return true;
else
Toast.makeText(context.getApplicationContext(), "No Internet Connection", Toast.LENGTH_LONG).show();
return false;
}