Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid store recorded audio using input text?
    primarykey
    data
    text
    <p>I have an app that records and stores the audio on the sdcard. It records and saves it in the right place, but saves it as android.widget.EditText@random number. I was using an EditText to get the filename.</p> <p>Does anyone know how I can let the user enter some text and save the file as that. I thought I was onto something with the code below, but no...</p> <pre><code>try { //Set user input as filename String filename = getInput.toString(); // set the storage directory to SDcard File storageDir = new File(Environment.getExternalStorageDirectory(), "audio"); storageDir.mkdir(); Log.d(APP_TAG, "Storage directory set to " + storageDir); outfile = File.createTempFile(filename, ".3gp", storageDir); //show filename System.out.println("File is: "+outfile.getAbsolutePath()); // initiate recorder recorder.setAudioSource(MediaRecorder.AudioSource.MIC); recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); recorder.setOutputFile(outfile.getAbsolutePath()); } catch (IOException e) { Log.w(APP_TAG, "File not accessible ", e); } catch (IllegalArgumentException e) { Log.w(APP_TAG, "Illegal argument ", e); } catch (IllegalStateException e) { Log.w(APP_TAG, "Illegal state, call reset/restore", e); } startRecord(); } else { stopRecord(); </code></pre> <hr> <p>here is my updated code:</p> <pre><code> //set filename to user input String filename = getInput.getText().toString()+".3gp"; // show filename System.out.println("File is: " + filename); // initiate recorder recorder = new MediaRecorder(); recorder.setAudioSource(MediaRecorder.AudioSource.MIC); recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); recorder.setOutputFile("/sdcard/audio/"+filename); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); player.setDataSource(filename); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload