Android DTMF send tone overriding
Asked Answered
R

2

0

I tried to programmatically send DTMF tones in Android. But the emulator shows up a dialog box that says "Do you want to send these tones?" and it sends the tones only if I click OK. But how can I programmatically overcome this dialog box?

Gracias

Regulation answered 15/1, 2012 at 14:37 Comment(1)
Can you post a fragment of your code, so we can see what API you are using?Maugham
F
8

In my application, I am sending DTMF tones (with gap using ","). Please see the code below. If you put number as: 12345,6,7 it will dial 12345 and send 6 and 7 as dtmf tone with gap.

String url = "tel:" + number;
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse(url));
startActivity(intent);
Fezzan answered 16/1, 2012 at 9:49 Comment(1)
Is there a way to verify if the DTMF tones reach the receiver device? I tried several variations of dialed numbers, but do not hear any DTMF tones on the receiver end.Anhwei
P
6
    /**
 * Dials a number with DTMF chars
 * Note: When the number is dialed, only the initial number is displayed on the device dialer
 * For example: dial("*6900,,1") will display only *6900 on the device dialer (but the rest will also be processed)
 * @param number
 */
public void dial(String number) {
    try {
        number = new String(number.trim().replace(" ", "%20").replace("&", "%26")
                .replace(",", "%2c").replace("(", "%28").replace(")", "%29")
                .replace("!", "%21").replace("=", "%3D").replace("<", "%3C")
                .replace(">", "%3E").replace("#", "%23").replace("$", "%24")
                .replace("'", "%27").replace("*", "%2A").replace("-", "%2D")
                .replace(".", "%2E").replace("/", "%2F").replace(":", "%3A")
                .replace(";", "%3B").replace("?", "%3F").replace("@", "%40")
                .replace("[", "%5B").replace("\\", "%5C").replace("]", "%5D")
                .replace("_", "%5F").replace("`", "%60").replace("{", "%7B")
                .replace("|", "%7C").replace("}", "%7D"));

        Uri uri = Uri.parse("tel:"+ number);
        Intent intent = new Intent(Intent.ACTION_CALL, uri);
        startActivity(intent);

    } catch (Exception e) {
        //getAlertDialog().setMessage("Invalid number");
        e.printStackTrace();
    }
}
Pulpiteer answered 20/10, 2012 at 6:54 Comment(2)
I was just wondering, are all these characters really convertable to DTMF signals? I was under the impression that there were only 0-9#*A-D. Trying to find a comprehensive list of them all. @Pinhassi Can you point me in the right direction?Alfy
Potential change from prior behavior: Replacing with above htmlencoded characters seems to have issues while dialing the number "telephone_number,1234" from telecom provider end: "The call cannot be completed as dial, please check the number and dial again"Anhwei

© 2022 - 2024 — McMap. All rights reserved.