Using tel: Hyperlinks on Android < 4 alternative?

I have an app which gives normal landline numbers for UK 08 numbers.

Currently this is a web page shown in the app, when the user finds the number they want and click on the green phone icon. I'm using the following JavaScript to force then force a tel: link with the number to bring up the dailer.

document.location.href = 'tel:'+number;//push browser to call number

This method works fine for all newer android 4.0 and above as far as i can see. But when i use my old Orange San Francisco Phone (android 2.3) it doesnt bring the dailer. Instead it just attempts to open a new page with tel:01xxxxxxxx as the URL which in turn displays a web page not available message.

I assume this is because tel: is part of HTML5 which is why it's not working. Is there any alternative that would work on all versions?

Answers


tel: is preferred - since the 1990's. callto: may work better for some devices. See also: How to mark-up phone numbers?

EDIT

Since you have the page running inside an Android WebView, you can handle this error with the hack (also described at Android WebView "tel:" links show web page not found):

myWebView.setWebViewClient(new WebViewClient() {  
    @Override  
    public boolean shouldOverrideUrlLoading(WebView view, String url) {  
        if (url.startsWith("tel:")) { 
            Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(url)); 
            startActivity(intent); 
        }
        else if(url.startsWith("http:") || url.startsWith("https:")) {
            view.loadUrl(url);
        }
        return true;  
    }  
} 

For which you may need the permission

<uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>

Need Your Help

How to raise the NotFound exception with DRF via the urls.py

python django django-urls

Can anyone confirm how you can raise the NotFound exception with DRF via the urls.py ?

get N-th byte from mmaped file

c memory segmentation-fault mmap coredump

I'm new at C and now I'm learning about mmap. I want to get N-th byte from mmaped file, but I get this error Segmentation Fault (core dumped) When I test my program with gdb I get that something is...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.