hash key "#" stripped from ussd code in "tel:" links on html pages
Asked Answered
L

4

9

Good day all. I have a simple link on a webpage, in where the user can call an USSD number:

<a href="tel:*111*2#" class="phoneCallButtonLink">*CLICK HERE AND CALL *111*2#</a>

this is pretty straight forward; now, if I test it on desktop browser, it popups an alert asking me if I want to call (with skype) the number *111*2#, and thats ok.

with my Android phone (S Note 3), when testing this page, the phone (or something) stripped out the last "#" (only the last) from the link, resulting in a call to *111*2.

does anyone has experienced this? or knows how to prevent this?

Loner answered 17/9, 2014 at 12:42 Comment(4)
Try to replace # with %23.Rysler
for some reason, the last hash encoded is seen as a %23Phonography
have you try my ans ?Rysler
Yes, I have tried with no luck, I try to encode directly and in various way with js... thelast hash is stripped, sounds like some kind of prevention by the phone to automatically deal ussd codes....Phonography
C
13

Use URL encoding for special character in a URL. For example # equals %23

This worked for me:

<a ng-href="tel:%23 224">#224</a>

As you can see:

enter image description here

Chaetopod answered 30/9, 2015 at 17:12 Comment(0)
B
4

You need to use Uri.encode("#") For example String number = "tel:*111*2" + Uri.encode("#");

Bocock answered 17/9, 2014 at 13:12 Comment(0)
R
2

Try this way,hope this will help you to solve your problem.

 webview = (WebView) findViewById(R.id.webview);
 webview.loadData("<a href=\"tel:*111*2#\" class=\"phoneCallButtonLink\">*CLICK HERE AND CALL *111*2#</a>","text/html", "utf-16");
 webview.setWebViewClient(new CustomWebViewClient());

 private class CustomWebViewClient extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView wv, String url) {
    if(url.startsWith("tel:")) {
       Intent intent = new Intent(Intent.ACTION_DIAL);
       intent.setData(Uri.parse(url.replace("#","%23")));
       startActivity(intent);
       return true;
    }
    return false;
   }
 }
Rysler answered 17/9, 2014 at 13:15 Comment(0)
V
0

You can use below way to display the USSD in dialer

<a href="tel:*111*2%23" class="phoneCallButtonLink">*CLICK HERE AND CALL *111*2#</a>
Votary answered 16/4, 2018 at 14:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.