Here I have the code which records a audio stream to file. The problem is I'd like to save this file with correct file extension (mainly .mp3 and .aac). How can I achieve this?
URLConnection conn = new URL(StringUrls[0]).openConnection();
InputStream in = conn.getInputStream();
BufferedOutputStream bufOutstream = new BufferedOutputStream(new FileOutputStream(new File(env.getExternalStorageDirectory()+"/temp.file")));
byte[] buffer = new byte[4096];
int len = in.read(buffer);
while (len != -1) {
bufOutstream.write(buffer, 0, len);
len = in.read(buffer);
if (Recorder.this.isCancelled) break;
}
bufOutstream.close();