【问题标题】:How to use Uri.parse() with # at the end如何在最后使用带有 # 的 Uri.parse()
【发布时间】:2013-05-15 16:35:04
【问题描述】:

我尝试使用 GSM 代码通过 Android 应用转移我的电话。 例如,如果我调用:**21*otherNumber# 我所有的电话都将转移到 otherNumber。

我的代码:

Uri transfert = Uri.parse( "tel:**21*" + numero + "#");
Intent intent = new Intent( Intent.ACTION_CALL, transfert );
startActivity(intent);

然而,Uri.parse() 有如下定义: " 一个 URI 引用包括一个 URI 和一个片段,URI 的组成部分跟在 '#' 后面"

所以,它删除了 # 但我需要它。没有它,GSM 代码将无法工作。

有人会有想法吗?

【问题讨论】:

    标签: android parsing uri gsm


    【解决方案1】:

    我认为您不能拨打带有分机号的电话号码,这是一个已知问题 (see this)。

    根据this thread,你可以尝试添加%23 like Uri.parse( "tel:**21*" + numero + "%23");

    【讨论】:

    • 我错过了这篇文章,谢谢它有效!我也会看看 ACTION_CALL。
    【解决方案2】:

    您需要发送一个 URI 编码的散列以通过 URI 对其进行解析。

    public static final String encodedHash = Uri.encode("#");
    

    它将保留 URI 编码的哈希并按照您指定的方式通过 GSM 发送 USSD 消息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-12
      • 1970-01-01
      • 2011-12-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多