0

我在 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();


}
4

2 回答 2

0

您的存储可能未安装。我尤其在 CyanogenMod 系统上遇到了默认情况下未安装 sotrages 的问题。只需调用以下命令即可确保已安装存储:

    boolean isMountend = Environment.getExternalStorageState().
equals(android.os.Environment.MEDIA_MOUNT‌​ED); 
于 2016-06-23T05:41:38.203 回答
0

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

于 2017-08-16T02:02:26.930 回答