【问题标题】:How to parse '#' simbol using Uri.Parse in android如何在 android 中使用 Uri.Parse 解析“#”符号
【发布时间】:2016-01-10 16:00:36
【问题描述】:

嘿...我正在编写这样的代码:

Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:*123#"));
startActivity(callIntent);

上面的callIntent是用来拨打电话号码*123#的,但是当我运行代码时,它只是在没有#的情况下拨打*123。我试过把'/'放在#前面,但结果是一样的,只是*123没有#...

我已经阅读了开发者 android 中的 Uri,然后发现了这个: 公共抽象字符串 getEncodedFragment () 但我真的不知道这个方法到底是做什么的......:)

任何人都可以帮助解决这个问题...?? :),关于如何使用 Uri.parse 获取该符号。 在此先感谢....我真的很感谢您的回答... :)

【问题讨论】:

    标签: android android-intent uri


    【解决方案1】:

    encodedHashencode # 字符。你可以用它

    String encodedHash = Uri.encode("#");
    startActivity(new Intent("android.intent.action.DIAL",
    Uri.parse("tel:"+ "*123"+ encodedHash)));
    

    【讨论】:

    • 是的..我正在使用 Uri.encode.. 它可以工作..谢谢.. ;)
    【解决方案2】:

    我认为你想要的不可能,快速搜索将引导你到this solution

    更多详情请关注here

    【讨论】:

    • 谢谢你让我看看你的链接... :)
    • 没问题,希望对您有所帮助。
    • 如果你有多个正确答案并且你接受另一个,至少要投票给其他有帮助的正确答案:)
    • 完成...ehehe...谢谢Simon先生...我还是新手... :D
    【解决方案3】:

    来自先生。西蒙链接...我找到了答案:)

    Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:"+Uri.encode("*123#")));
    

    所以我只是添加了 Uri.encode("*123#");并且“#”仍然存在....

    感谢 aaaa looot 西蒙先生...呵呵呵呵.. :)

    【讨论】:

    • 很高兴我能帮上忙。编码愉快。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-09
    • 2017-01-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多