Android DTMF发送音调覆盖

niv*_*ard -1 android telephony dtmf

我尝试以编程方式在Android中发送DTMF音.但是模拟器会显示一个对话框,上面写着"你想发送这些音吗?" 它只在我点击OK时发送音调.但是,我如何以编程方式克服此对话框?

格拉西亚斯

Dha*_*ora 7

在我的应用程序中,我正在发送DTMF音(使用","表示间隙).请参阅下面的代码.如果您将数字设置为:12345,6,7它将拨打12345并发送6和7作为dtmf音调与间隙.

String url = "tel:" + number;
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse(url));
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)


Asa*_*ssi 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();
    }
}
Run Code Online (Sandbox Code Playgroud)