2012-01-15 81 views
-1

我试图以编程方式在Android中发送DTMF音调。但是模拟器显示一个对话框,显示“你想发送这些音调吗?”并且只有当我点击确定时它才发送音调。 但是我怎样才能以编程方式克服这个对话框?Android DTMF发送音调覆盖

格拉西亚斯

+2

您可以发布您的代码的片段,所以我们可以看到你所使用的API? – JoxTraex 2012-01-15 14:42:12

回答

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); 
+0

如果您觉得这是正确的答案,请接受它。 – 2012-06-03 17:47:44

5
/** 
* 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(); 
    } 
} 
+0

我只是想知道,所有这些字符是否可以转换为DTMF信号?我的印象是只有0-9#* A-D。试图找到他们所有的全面清单。 @Pinhassi你能指点我的方向吗? – 2014-02-15 17:45:28