So I have this code, that takes my current call and plays the DTMF tone:
if (CallManager.currentCall != null) {
when (pressed) {
10 -> CallManager.currentCall?.playDtmfTone("*".toCharArray()[0])
11 -> CallManager.currentCall?.playDtmfTone("#".toCharArray()[0])
else -> CallManager.currentCall?.playDtmfTone(pressed!!.toChar())
}
}
But I make a call, for example to a big firm. and the machine enters. "For sales press 1, for accounting press 2" and so on I press on my view for the layout, and the code gets called, the current call exists, but even so, the call does not take my input. It doesn't respond to what I pressed. What am I doing wrong?
I tried multiple default dialers and found that Drupe: https://play.google.com/store/apps/details?id=mobi.drupe.app&gl=NL Can send the DTMF tones, so I assume this is possible.
This fixed it:
fun pressed(pressed: Int?) {
if (SIPManager.instance != null && SIPManager.instance?.numberOfActiveCalls ?: 0 > 0) {
SIPManager.instance!!.sendDTMF(null, pressed)
}
if (CallManager.currentCall != null) {
when (pressed) {
10 -> playDTMF("*".toCharArray()[0])
11 -> playDTMF("#".toCharArray()[0])
else -> playDTMF(pressed!!.toString().toCharArray()[0])
}
}
}
fun playDTMF(value: Char) {
Log.i("DTMF", "DTMF char is: " + value)
CallManager.currentCall!!.playDtmfTone(value)
Handler().postDelayed({
CallManager.currentCall!!.stopDtmfTone()
}, 250)
}
Was sending wrong chars