开发者

How do I send DTMF tones and pauses using Android ACTION_CALL Intent with commas in the number?

I have an application that calls a number stored by the user. Everything works okay unless the number contains commas or hash signs, in which case the Uri gets truncated after the digits. I have read that you need to encode the hash sign but even doing that, or without a hash sign, the commas never get passed through. However, they do开发者_StackOverflow get passed through if you just pick the number from your contacts. I must be doing something wrong. For example:

String number = "1234,,,,4#1";
Uri uri = Uri.parse(String.format("tel:%s", number));
try {
  startActivity(new Intent(callType, uri));
} catch (ActivityNotFoundException e) { ...

Only the number '1234' would end up in the dialer.


Hashes and commas are reserved characters in URLs. Hence, convert both of those (comma is %2C, hash is %23) and see if that helps.


Works for me with ',' , '*' & '#':

Intent intentCallForward = new Intent(Intent.ACTION_CALL);                             
Uri uri = Uri.fromParts("tel", phoneNumber, "#"); 
intentCallForward.setData(uri);                                
startActivity(intentCallForward); 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜