" has to listen to music"
..."either playing on the phone"
Wont work, Android doesn't support that.
..."or picked up by the device's mic"
Will work in some cases (i.e. when using the loudspeaker in a low-noise environment), but quality will be pretty bad.
Another alternative is to use the Visualizer class to grab audio data from session 0 (the global output mix). The quality of the audio will be pretty bad, but it might be good enough for BPM calculation, and it will work even if the music is routed to a headset.