【问题标题】:Android DTMF send tone overridingAndroid DTMF 发送音覆盖
【发布时间】:2012-01-15 14:37:14
【问题描述】:

我尝试在 Android 中以编程方式发送 DTMF 音调。但是模拟器会显示一个对话框,上面写着“你想发送这些音调吗?”只有当我单击确定时它才会发送音调。 但是我怎样才能以编程方式克服这个对话框呢?

感谢

【问题讨论】:

  • 您能否发布一段代码,以便我们查看您使用的是什么 API?

标签: android telephony dtmf


【解决方案1】:

在我的应用程序中,我正在发送 DTMF 音调(间隔使用“,”)。 请看下面的代码。如果您输入号码为:12345,6,7,它将拨打 12345,并以 dtmf 音调发送 6 和 7。

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

【讨论】:

  • 有没有办法验证 DTMF 音是否到达接收设备?我尝试了几种不同的拨号号码,但在接收端听不到任何 DTMF 音。
【解决方案2】:
    /**
 * 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();
    }
}

【讨论】:

  • 我只是想知道,所有这些字符真的都可以转换为 DTMF 信号吗?我的印象是只有0-9#*A-D。试图找到所有这些的完整列表。 @Pinhassi 你能指出我正确的方向吗?
  • 与先前行为的潜在变化:从电信提供商端拨打号码“telephone_number,1234”时替换为上述 htmlencoded 字符似乎有问题:“呼叫无法作为拨号完成,请检查号码再拨”
猜你喜欢
  • 1970-01-01
  • 2023-01-12
  • 1970-01-01
  • 1970-01-01
  • 2014-08-13
  • 2012-11-23
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多