Rafferty
Rafferty

Reputation: 1037

Android AudioRecord StartRecording - Application Hang

I have been trying to get my Android App to use the mic and start recording. But the app just keeps crashingon the AudioRecord StartRecording() method.

_recorder = new AudioRecord(AudioSource.Mic, RECORDER_SAMPLERATE, RECORDER_CHANNELS, RECORDER_AUDIO_ENCODING, _bufferSize);

        if (_recorder.State == State.Initialized)
            _recorder.StartRecording();  // <-- HANGS ON THIS LINE

Please help. Do I need to place StartRecording in a thread or something?

I am using Xamarin Android, with code based on http://www.edumobile.org/android/audio-recording-in-wav-format-in-android-programming/

Upvotes: 1

Views: 625

Answers (2)

Rafferty
Rafferty

Reputation: 1037

to answer my question - with clues from Vyshak (THANKS). It appears that StartRecording should really be called in a separate thread (which makes me wonder why a lot of sample codes do not do this).

A good reference point for anyone doing this in the future will be this sample code right here: https://developer.xamarin.com/samples/monodroid/Example_WorkingWithAudio/

Upvotes: 1

VYSHAK M
VYSHAK M

Reputation: 86

if You are sure that the code is correct then Use Async Task.it Will Work

Upvotes: 1

Related Questions