Search code examples
androidaudiorecordandroid-audiorecord

How to limit record time with AudioRecord as MediaRecorder with setMaxDuration


I need to stop AudioRecord after 2 minutes from the starting time. With MediaRecorder I use setMaxDuration and this work well, but I need a good approach with AudioRecord too.

Thank's for help


Solution

  • You can try like this..

    handler=new Handler();
     Runnable r=new Runnable() 
    {
     public void run() 
    {
      recorder.stop();
       recorder.release(); 
      } 
    
    };
    handler.postDelayed(r, 120000);