Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check whether another Recorder is running or not?

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?

like image 601
Raneez Ahmed Avatar asked Jul 04 '13 13:07

Raneez Ahmed


People also ask

Can voice recorder run in the background?

Smart Recorder is the best secret voice recording app for Android users. The app can record surrounding voice even when the display is off.


1 Answers

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".

like image 200
Raneez Ahmed Avatar answered Sep 25 '22 20:09

Raneez Ahmed