
Now this might become a slightly controversal app as it is not free (0.50€, but remember, that you may return it within 24h without paying) and it will probably not work for some phones and some setups.
However, here is the idea:
This app sends 5-10 short sounds (they sound like clicks, but they are slightly more complicated) and measures the timing of their echos to calculate the according distance.
Here is a demo video: YouTube - Android App: Sonar
The problems you might face with this are mostly an unfortunate phone layout (i.e. speaker and mic on opposite sides) and environments in which it is hard to determine the "correct" echo because of too many sonic reflections from many directions. You may find more information within the app.

If you try it, please tell me which device you used and how good it works for you.
BTW: I designed it on a HTC Desire and find stone walls are a good first try, if they are the closest "hard" obstacle.
Search for "sonar" or use this: