Domanda

I use AudioRecord API to record audio (WAV) in my app, and it records successfully. But my app behaves strange when i try to record while other recording apps are running in the background.

The MediaRecorder API throws exception when attempting to start recording while another recorder is running but the AudioRecord API initializes the recorder instance and doesn't throw any exceptions, so i cant identify whether any recorder instance is running or not.

This scenario has been handled in Samsung S3's default Voice Recorder, when i try to record it says

" Unable to start new recording. Other applications already recording"

How can i identify whether any other recorder is running or not before my app's recorder starts?

È stato utile?

Soluzione

I have found solution to this problem

Since the AudioRecord doesn't throw any exceptions unlike MediaRecorder API, i have gone for another workaround.

When another recorder instance is running i have found that the read method returns 0 instead of ERROR_INVALID_OPERATION or ERROR_BAD_VALUE. So if the first read operation returns 0 , i showed an error message as "Recorder cannot be initialized".

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top