How to flush rewrite rules on the activation of any plugin

  1. Add your rewrite rules on the init action hook.

  2. In your personal activation function, both a) add the rewrite rules and b) flush the rewrite rules. One time. This is the only time you need to flush the rules.

Alternatively, if your rewrite rules can change through user input, then you need to flush them when the rules change, not at any other time. You still need to add them on init though.