2012-01-15 82 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