It takes a few minutes to shut down and restart the phone, it would sometimes be handy to be able to swap batteries without shutting down (i.e. swap in a fully charged battery before going out). Will the phone operate without a battery while connected to a wall charger? Is it safe to swap the battery without shutting down?
I just tried this on two phones, a Samsung Galaxy 551 and a Samsung Galaxy S. It doesn't work. The phones typically just shut off. However, one time the Galaxy S didn't shut off right away but I wasn't able to put the battery back in before it shut off. My Google Nexus S is made so that you can't even take the back cover off without unplugging it.
I suspect that this is simply not a supported feature in most phones and that you're not likely to find that it works anywhere. Not to mention the fact that power-loss may damage components or corrupt data. This is one reason why the phone monitors the battery life and shuts down if there isn't enough battery power.
It's device dependent, if the manufacturer can fit in the circuitry to use the wall charger without the battery then yes you'd be able to do that. Most laptops can run without batteries, I doubt many smartphone does though; phones are primarily designed to be used while on the go, while laptops are more likely to be plugged in.
A safe test is to shutdown the phone normally, plug the phone into charger, and pull out the battery, then try booting up the phone with only wall charger. If you can boot up, then it's 90% likely that you'll be able to pull out the battery while it's running without causing a reboot.
Is it safe to swap the battery without shutting down?
If the phone doesn't have the appropriate circuitry, it will be no less safe than just unplugging the battery. There is no moving parts in a mobile phone and all modern hardware are designed such that complete loss of power will just reinitialize the hardware as if it's just booting up. Therefore the only possible damage you can do is to the file system.
Modern journalled file systems are designed to be able to withstand power loss. If you're using journaled filesystem, e.g. ext3 or ext4, then your data should be safe; if using unjournalled filesystem, e.g. FAT or ext2, then there is a small chance of file system corruption.
Does your user manual have any prohibitions about removing the battery while plugged in? That would be my first point of information. And I probably wouldn't try it myself, but that's just me.
The issue is that you have no idea of whether the folks who designed the charge circuit accounted for this or not, and you don't know how they did the charging circuit, so you don't know for sure whether it's safe or not to try it.
I'm GUESSING that it won't hurt your phone because the designer should be doing something safe for the 'battery goes missing' case. I also wouldn't be surprised if the phone either just cut out, or went into it's 'oh noez, the battery is out of juice' routine and turned itself off right away.
Just for completeness sake I want to share that I've operated my old LG GT 540 countless times with the battery removed, while the USB cable is plugged in. I can power it up on in these situations (and run CWM). So I guess that there might be more LG Android phones with similar circuitry. Since I've upgraded to my new Galaxy S2, I've been too reluctant to try it out.
A smartphone's most limited resource is its battery. This means phones are specifically designed to survive power losses. And imagine a hang up with a subsequent reboot would brick with some probability. How many complaints would that cause?
So the answer is simple:
Just try out to switch your battery. If it works: Fine.