score:1

Accepted answer

i'm still not sure what was the problem, but i think there was something wrong with the way i stopped recording (the whole try, catch thing). i just rewrote the whole code and put the mediarecorder in two different methods. startrecording() and stoprecording() method. and now it works perfectly!

startrecording()

public void startrecording (){
     recorder = new mediarecorder();
     recorder.reset();      
     recorder.setaudiosource(mediarecorder.audiosource.camcorder);
     recorder.setoutputformat(mediarecorder.outputformat.three_gpp);
     recorder.setaudioencoder(mediarecorder.audioencoder.amr_nb);
     if (environment.getexternalstoragestate().equals(environment.media_mounted))
     {
         externalstoragepath = environment.getexternalstoragedirectory().getabsolutepath();
         externaloutputpath = externalstoragepath + file.separator + "/android/data/com.whizzappseasyvoicenotepad/test.mp3";
         recorder.setoutputfile(externaloutputpath);
     }
     else
     {
        storagepath = environment.getdatadirectory().getabsolutepath();
        recorder.setoutputfile(storagepath + "/android/data/com.whizzappseasyvoicenotepad/test.mp3");
     }
     recorder.setonerrorlistener(errorlistener);
     recorder.setoninfolistener(infolistener);

     try {
        recorder.prepare();
        recorder.start();
    } catch (illegalstateexception e) {
        // todo auto-generated catch block
        e.printstacktrace();
    } catch (ioexception e) {
        // todo auto-generated catch block
        e.printstacktrace();
    }
}

stoprecording()

public void stoprecording() {
    if (null != recorder) {
        recorder.stop();
        recorder.reset();
        recorder.release();

        recorder = null;
    }
}

Related Query

More Query from same tag