hash key “#” stripped from ussd code in “tel:” links on html pages

前端 未结 4 1009
夕颜
夕颜 2021-01-05 01:03

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

*CLIC         


        
相关标签:
4条回答
  • 2021-01-05 01:40

    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:

    0 讨论(0)
  • 2021-01-05 01:49

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

    0 讨论(0)
  • 2021-01-05 01:50

    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>
    
    0 讨论(0)
  • 2021-01-05 01:52

    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;
       }
     }
    
    0 讨论(0)
提交回复
热议问题