I am develop a Voip Application using cSipSimple. now i want to show a busy tone when third party app call are coming (whatsapp, instagram and etc.)now the scenario is that i am on my voip call and some one call on my GSM number and i am picking up phone my voip call is automacitally going on to Hold but the next scenario is that when third party app calling and i am picking up that time my voip call is continue and third party call not working. now i want when third party app calling and i am picking up call my voip call putting on hold and i am connect with third party call. is there any method or receiver to detect third party call are coming??
i am try this How do I detect skype/telegram/whatsapp calls when my messenger app is in a call or wants to make a call? but its didn't work.
I am using this code for Detecting GSM Call and put my voip call on hold.
public void onGSMStateChanged(int state, String incomingNumber) throws SameThreadException {
// Avoid ringing if new GSM state is not idle
if (state != TelephonyManager.CALL_STATE_IDLE && mediaManager != null) {
mediaManager.stopRingAndUnfocus();
}
// If new call state is not idle
if (state != TelephonyManager.CALL_STATE_IDLE && userAgentReceiver != null) {
SipCallSession currentActiveCall = userAgentReceiver.getActiveCallOngoing();
// If we have a sip call on our side
if (currentActiveCall != null) {
AudioManager am = (AudioManager) service.getSystemService(Context.AUDIO_SERVICE);
if (state == TelephonyManager.CALL_STATE_OFFHOOK) {
// GSM is now off hook => hold current sip call
hasBeenHoldByGSM = currentActiveCall.getCallId();
callHold(hasBeenHoldByGSM);
pjsua.set_no_snd_dev();
am.setMode(AudioManager.MODE_IN_CALL);
} else {
// We have a ringing incoming call.
// Avoid ringing
hasBeenChangedRingerMode = am.getRingerMode();
am.setRingerMode(AudioManager.RINGER_MODE_SILENT);
// And try to notify with tone
if (mediaManager != null) {
mediaManager.playInCallTone(MediaManager.TONE_CALL_WAITING);
}
}
}
} else {
// GSM is now back to an IDLE state, resume previously stopped SIP
// calls
if (hasBeenHoldByGSM != null && isCreated()) {
pjsua.set_snd_dev(0, 0);
callReinvite(hasBeenHoldByGSM, true);
hasBeenHoldByGSM = null;
}
// GSM is now back to an IDLE state, reset ringerMode if was
// changed.
if (hasBeenChangedRingerMode != null) {
AudioManager am = (AudioManager) service.getSystemService(Context.AUDIO_SERVICE);
am.setRingerMode(hasBeenChangedRingerMode);
hasBeenChangedRingerMode = null;
}
}
}
Thanks in advance and help will be appreciate!!