The short answer is: NO, there is no out-of-the-box way to do this.
The long answer is: It depends on how much work you want to put into this. By definition, you cannot know which of the many networks is your friend's WiFi network (he/she could be in a spot where there are multiple networks). So there is no way you can preset your product to work with "any network". On top of that, there are unsecured, secured (WEP) and secured (WPA/WPA2) networks, each requiring a slightly different authentication process. You can easily see how a "one-size-fits-all" wouldn't work.
That said, there are a couple of things you could look into:
- You could look into using WPS - this is a way to autoconfigure the setup of the network for networks where the WiFi router support WPS. Just note that there are serious security flaws in WPS, and that WPS is not something everyone will have turned on.
- You could use the method employed by Google for their Chromecast (and used by other devices as well): Upon first boot, the wifi dongle in your Pi acts as a wireless Access Point. Anyone wanting to use your product connects to the WiFi network broadcast by your Pi, and uses it to configure the Pi with a network SSID and password (via a webpage the Pi serves up - you would need to build this webpage). Then the Pi configures the WiFi adapter with this info, resets it and turns it back into a "normal" WiFi dongle to connect using the credentials you gave it. EDIT: Use the
hostapd
package for the Access Point functionality