I use Audio Record to record audio and Media Codec to convert raw .WAV data buffer to Flac buffer. This Flac buffers are then written to a file which is not playable. As I looked at Flac file format, it requires file header and frame header/footer in order to be playable.
This is also the issue with other formats such as audio/mp4a-latm, audio/3gpp, audio/amr-wb (which are Android already support encoders)
For audio/mp4a-latm, I successfully add file header, frame header/footer by follow this SO. For Flac and other format, is there any wrapper/library to do this (rather than read long/complicated file format document)?