Use this method in your Activity and call this when you want to know whether the net is available or not. 
public boolean isInternetOn(Context ctx) {
    this.mContext = ctx;
    ConnectivityManager Connect_Manager = (ConnectivityManager) mContext
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    State connected = NetworkInfo.State.CONNECTED;
    State connecting = NetworkInfo.State.CONNECTING;
    State disconnected = NetworkInfo.State.DISCONNECTED;
    State info0 = Connect_Manager.getNetworkInfo(0).getState();
    State info1 = Connect_Manager.getNetworkInfo(1).getState();
    // ARE WE CONNECTED TO THE NET
    if (info0 == connected || info0 == connecting || info1 == connecting
            || info1 == connected) {
        // MESSAGE TO SCREEN FOR TESTING (IF REQ)
        // Toast.makeText(this, connectionType + " connected",
        // Toast.LENGTH_SHORT).show();
        Log.d("Internet", "Connected");
        return true;
    } else if (info0 == disconnected || info1 == disconnected) {
        Log.d("Internet", "DisConnected");
        // System.out.println("Not Connected");
        return false;
    }
    return false;
}
Now to check Internet Conncetion,
if (isInternetOn(this))
     {
        //Do stuff          
      }
else
       {
           //show alert
        }