【问题标题】:Android call intent with '#' sign as number, prevent Uri.parse remove #Android呼叫意图以'#'符号作为数字,防止Uri.parse删除#
【发布时间】:2017-08-21 12:52:45
【问题描述】:

我想拨打一个带有“*140*​​123456#”或“141#123456#”的号码。但是Uri.parse(phoneNumber) 方法会删除它之后的所有“#”符号和数字。有什么解决办法?

【问题讨论】:

    标签: android android-intent uri


    【解决方案1】:

    试试这个:

    operator = 123
    String UssdCodeNew =  "*" + operator + Uri.encode("\u0023");
    

    【讨论】:

      【解决方案2】:

      我遇到了同样的问题,并通过将字符串中的# 替换为%%23 来解决它。

      【讨论】:

        【解决方案3】:

        【讨论】:

        • 感谢您的回答。我将其更改为String s = Uri.encode("*141*"+editText.getText().toString()+"#"); intent.setData(Uri.parse("tel:"+s));,但它不起作用。
        • 我只需要编码'#'符号,它工作得很好。谢谢
        【解决方案4】:

        检查this

        # 应该是\u0023

        【讨论】:

        • 感谢您的回答,但还是有这个问题。
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多