开发者

Android: Using MIC (via setAudioSource) crashes

I am developing my first app on the G1, with firmware 2.2, and my code crashes on the emulator and on the phone when I try to run it.

I have the following:

public voi开发者_运维知识库d onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Prepare recorder source and type
    recorder = new MediaRecorder();
    recorder.setAudioSource(MediaRecorder.AudioSource.MIC);

The code will crash on the last line, when trying to execute recorder.setAudioSource(MediaRecorder.AudioSource.MIC).

After a few Google searches, it seems like a lot of people are having this problem but I cannot find any solutions for it!

Does anyone know why this is happening and how to fix it please?

I would really appreciate it,

Thank you,

Jary


I found the solution, it has to be:

<uses-permission android:name="android.permission.RECORD_AUDIO"/>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜