拨打电话时,哈希按钮无效

时间:2017-12-26 08:54:50

标签: java android

我正在制作拨号盘,但是当我拨打* 123#时,它只拨打* 123。我的#按钮没有显示。请帮帮我。 我的代码是:

String s = buttonHesh.getText().toString();
editText.setText(editText.getText().toString() + s);

1 个答案:

答案 0 :(得分:1)

你可以使用Uri.encode()函数来完成它。

String number = "*101#";
number =  number.replace("*", Uri.encode("*")).replace("#",Uri.encode("#"));
String uri = "tel:" + number;

Intent intent;
intent = new Intent(Intent.ACTION_CALL, Uri.parse(uri));

或者替换

String uri = "tel:" + " *101%23 ";

Intent intent;
intent = new Intent(Intent.ACTION_CALL, Uri.parse(uri));