java.lang.IllegalStateException at android.media.MediaRecorder.start(Native Method)

前端 未结 5 2017
别那么骄傲
别那么骄傲 2021-01-14 12:22

I want to make a voice recorder app but it crashes when i click the \"Start Recording\" button. I get an error saying java.lang.IllegalStateException at android.media.Media

5条回答
  •  遥遥无期
    2021-01-14 13:03

    You have to take into consideration, that MediaRecorder as well as MediaPlayer has their state machines, which obligate you to do some action in specific sequence.

    Here you tried to start recording withou preparing MediaRecorder. Call

    recorder.prepare();
    

    Before:

    recorder.start();
    

提交回复
热议问题