首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >录音机重新启动

录音机重新启动
EN

Stack Overflow用户
提问于 2013-05-17 19:47:25
回答 1查看 154关注 0票数 0

我已经创建了录音器。当旋转我的设备时,音频将自动保存。我怎样才能避免这种情况?我在设备上使用的是Android 4.1.1。

代码语言:javascript
复制
   private MediaRecorder mRecorder = null;
     private static final String LOG_TAG = "MediaAudioCapture";
     ImageButton button_audio_button = (ImageButton) findViewById(R.id.audio_button);
      button_audio_button.setOnClickListener(new OnClickListener() {
      public void onClick(View record_button) {
      ImageButton audio_button = (ImageButton) record_button;
      if (!started_note_recording) {
        if (!started_recording) {
          startRecording();
          audio_button.setImageResource(R.drawable.audio_red);
         } else {
         stopRecording();
         audio_button.setImageResource(R.drawable.audio);
         }
        }
      }
     });
    private void startRecording() {
    mRecorder = new MediaRecorder();
    mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
    mRecorder.setOutputFile(output.getAbsolutePath());
    mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
    ImageButton button_audio_button = (ImageButton)findViewById(R.id.audio_button);
    button_audio_button.setImageResource(R.drawable.audio);
    }
   }
  });
    try {
      mRecorder.prepare();
     } catch (IOException e) {
   Log.e(LOG_TAG, "prepare() failed");
   }
  mRecorder.start();
  stopWatch.start();
   }
EN

回答 1

Stack Overflow用户

发布于 2013-05-17 20:03:17

这是因为当您轮换时,活动将被重新加载。您可以将方向固定为纵向,或者您必须更改您的逻辑以保持旋转状态。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16608252

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档