Android Verificar conectividade

Verifique se seu aplicativo tem conectividade

boolean hasConnectivity = true;
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo info = cm.getActiveNetworkInfo();
hasConnectivity
= info != null
&& (info.isConnected()
|| (roamingOK && info.isRoaming()));