Question: I am compiling against a library that creates an AudioRecord object that captures the microphone input of my tablet.

I don't have the ability to modify the precompiled library, but I want to feed it some pre-recorded audio.

Is there a way to create some sort of loopback in android to accomplish this? 

Thanks.

Answer: 
Android does not (at the time of writing) support this functionality. You as an app developer can't replace the microphone path with some other audio source.

Some platforms do support this kind of functionality. For example, I've done loopback of audio on Qualcomm's APQ8064 platform by connecting one of the `MultiMedia` DAIs to the `AFE_PCM_RX` audio mixer, and the `AFE_PCM_TX` DAI to the `MultiMedia` audio mixer, and then reading from the `AFE_PCM_TX` device. But this is obviously very platform-specific, it requires you to have a rooted device (and possibly access to the full source code for the device so that you can make a custom ROM), and a good understanding of the platform in question.  

TL;DR: it's generally not worth the effort to attempt this.
Yes, there is an elegant tool developed by the chrome audio team, termed the Rick O'Rang loopback cable. It does a pretty good job of looping. It will take the audio input that comes out through the audio output channel and then feeds it back through the mic.

The hardware can be found here-->
<https://source.android.com/devices/audio/images/loopback_circuit.png>

There is an app that comes with it and can be found in Playstore, used to do extensive analysis of Latency and other audio parameters. But since all you need is to play something and record it, you can just assemble it, plug it into the audio jack and play things and it will do.