Q:

How to detect remaining capacity in a Lithium-ion battery? 

I need my device to have multiple power sources, and connect to different power supplies depending on power availability.  Each power source is a different rechargeable, Lithium-ion battery like this one.  I am wondering what sensors/techniques/devices/etc.  exist so I can determine "Battery #1 has 43% charge remaining, while Battery #2 is at 7%.  Use Battery #1." 
Clearly this is possible since all of our 'smart phones' predict with decent accuracy how much charge/capacity remains.  Thoughts? 

A:

The term you're looking for is "gas gauging."  This is usually done with dedicated ICs, measuring voltage and current.  TI and Linear Tech are couple of the big players. 

A:

Thing to keep in mind with determining state-of-charge of batteries is that their voltage is only a rough indication of that, and particularly when they're under load their internal resistance changes their voltage output, which misleads you into thinking they're at a lower SoC than they actually are.   This is particularly the case with Lithium chemistry batteries, because their discharge-vs-time curve is comparatively flat (not perfectly flat, just flatter than other chemistries) for most of their capacity (except the start & end). 
"Professional" battery SoC calculation is done by integrating the area under the current-vs-time curve, essentially to count how many coulombs of energy is going into or out of the battery, & comparing that to either (a) the theoretical/designed coulomb capacity of the battery, or (b) keeping track over long periods of time how many coulombs you get out of a 'full charge', which is preferable because this drops as the battery ages. 
Encapsulated batteries like are in laptops & cell-phones have these chips built into the case of the battery (along with the battery protection module), and the host CPU can interrogate the battery to find out its SoC as a neat & fairly accurate %age. 
Allowing your gadget to operate all the way down until it turns itself off, once in a while, is a good way letting the 'gas-guage' chip update its total-coulomb-capacity measurement. 
As @Matt Young said, there are many 'gas gauge' battery management chips out there for doing this. 
related:
http://jeelabs.org/2012/11/26/watts-amps-coulombs/
Why are batteries measured in ampere-hours but electricity usage measured in kilowatt-hours?