录音后找不到音频文件

时间:2016-06-21 11:28:54

标签: android avaudiofile

我在android studio中创建了一个录音机,但是我无法在手机上找到录制的文件。通常我的意思是将它附加到将要发送的电子邮件,但我无法在手机上找到它,以便我将其添加为附件。这是我的代码,如下所示

   private String outputFile = null;

   private MediaRecorder mRecorder;

    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);


    outputFile = Environment.getExternalStorageDirectory().getAbsolutePath() + "/recording.3gpp";
    }




     public void startRecording() throws Exception {



    if(mRecorder!=null){
        mRecorder.release();
    }

    File fileOut = new File(outputFile);

    if(fileOut!=null){
        fileOut.delete();
    }


    mRecorder = new MediaRecorder();
    mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
    mRecorder.setOutputFile(outputFile);
    mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);


        mRecorder.prepare();

    mRecorder.start();
}





public void stopRecording() {

    if(mRecorder != null) {
        mRecorder.stop();
        mRecorder.release();
    }
}

public void record(){



    new CountDownTimer(10000, 10000) { // 5000 = 5 sec

        public void onTick(long millisUntilFinished) {
            try {
                startRecording();
            } catch (Exception e) {
                e.printStackTrace();
            }
            Toast.makeText(HomeActivity.this, R.string.record_audio, Toast.LENGTH_LONG).show();
        }

        public void onFinish() {
            stopRecording();
            mProgressDialog.dismiss();
            Toast.makeText(HomeActivity.this, R.string.record_saved, Toast.LENGTH_LONG).show();
        }
    }.start();


}

2 个答案:

答案 0 :(得分:0)

您的存储空间可能未安装。我特别在CyanogenMod系统上面对默认情况下未安装sotrages。只需通过调用:

确保存储已安装
    boolean isMountend = Environment.getExternalStorageState().
equals(android.os.Environment.MEDIA_MOUNT‌​ED); 

答案 1 :(得分:0)

当您通过电缆连接以复制它们时,它们不会显示。您需要通过WiFi连接打开手机上的录音,然后右上角点击选项。可以选择将其上传到Google云端硬盘。将其上传到您的帐户后,将其下载到您的桌面驱动器。