No I dont think it can go off in an aerosol can.
The flies around hear - I'm sure they sniff it up like Coke because it certainly has no effect what-so-ever. Wasps seem to succumb, but flies, no.
Douglas, if you look real, real close, you'll see that those pesky fruit flies wear gas masks (some even have scary faces painted on them). You have to catch them and remove their masks before spraying them. Then, if it still doesn't work, hit them with the can.