ive just come across a simple solution that may work for others who have this problem occuring. (after attempting cleaning, restoring, hard resetting, and updating (to v5.0.1) failed to relieve the issue) (this worked for my iphone 4 by the way......)
When trying to figure out what was causing the popup / external speaker disablement, i noticed that when my iphone was connected to the dock connector cable, everything would work fine (no popup or speaker disablement). The odd thing however was that the dock connector didnt need to be connected to anything else on the usb end of things. Even though the iphone wasnt technically plugged into an accessory (as no signal would have been going through the cable, seeing as the usb end was not plugged into anything), my phone must have thought that it was, hence the error did not arise again whilst connected.
Rather than walking around with a cord constantly attached to the iphone dock port, i instead bought a case which included dock and headphone jack protectors. (little pieces of plastic / rubber that would prevent dust gettign into the docks).
Inserting this protector into the dock resulted in the same effect as if id plugged in the dock cable itself.
The best way i tested to see if this worked, was to open the ipod music player and play a song. When the rubber dock protector was inserted in the phone, all functionality was normal. After about 5-10 seconds (this consistenltly occured) of removing the rubber dock protector, the volume control bar would disappear in the music player, and external speakers were once again disabled. Upon reinserting the dock protector, everything reappeared and all functionality resumed correctly.
This may be a simple solution for those who currently have had no luck. I have only had my iphone for 4 months, and it has not been victim to water damage.
The brand of the iphone 4 case was SwitchEasy, and cost about $40.