Reputation: 7288
I have built an app that listens to background noise. I've found though that when listening the user cannot make calls or use any other app that records audio. I'm wondering if there's a way to either allow both to record audio or to explicitly disable sound whilst a call is before made? How would this be achieved?
Upvotes: 0
Views: 456
Reputation: 204
No.
Such things like recording audio, cannot be done with two apps at once (not while complying with Google Play guidelines). This means you have to listen for when another app wants the MediaRecorder
, or when a phone call intent is sent out to the operating system, and release it. You may also just listen to the devices call state.
You can use the TelephonyManager to listen in:
public class PhoneListener extends PhoneStateListener {
private Context context;
public PhoneListener(Context c) {
context = c;
}
public void onCallStateChanged (int state, String incomingNumber) {
switch (state) {
case TelephonyManager.CALL_STATE_IDLE:
break;
case TelephonyManager.CALL_STATE_RINGING:
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
break;
}
}
}
You should look at this for more detail: https://stackoverflow.com/a/15564021/4167644
Upvotes: 1
Reputation: 117
You could try to close the application while calling or have a button that activates a sleep for some time:
Snippet for sleep code: public void run() { try { Thread.sleep(300000); // Code } catch (Exception e) { e.getLocalizedMessage(); } }
Upvotes: 0