If you have fruit flies inside your home, a great tip is to make sure you are only storing fresh fruit. Fruit flies feed on the fungus that results from rottening fruit.  Leaving fruit out to ripen, which is really just the beginning of the rotting process, results in the production of ethylene gas, which fruit flies adore. If you must leave fruit out to ripen, make sure it doesn't over-ripen by checking it every day.
If you're fighting to keep fruit flies from invading your garden waste recycling bin, there are some steps you can take to make it uninviting to these pests. If you can't wait until recycling pickup day to place food scraps inside the bin, make sure you bury them well. Place a layer of grass and leaves or shredded paper over the scraps; fruit flies do not burrow though things in order to lay eggs.  Also make sure the lid is tightly secured and that there are no unplugged holes in the bin.