Can I make a phone call from HTML on Android?

AndroidHtmlPhone Call

Android Problem Overview


To make a phone call via HTML on an iPhone I create an <A/> tag with an href formatted as: <a href='tel:123-555-1212'>Dial Me</a>.

Is there an equivelant for HTML on Android?

CLARIFICATION - using the format href='tele:123-555-1212' does indeed work on on android. I was testing the app within a native Java wrapper on the device. It does not appear as if we can make a call from a web application hosted in a Native Wrapper.

Android Solutions


Solution 1 - Android

Yes you can; it works on Android too:

> tel: phone_number
> Calls the entered > phone number. Valid telephone numbers > as defined in the IETF RFC 3966 are > accepted. Valid examples include the > following: > > * tel:2125551212 > * tel: (212) 555 1212

The Android browser uses the Phone app to handle the “tel” scheme, as defined by RFC 3966.
Clicking a link like:

<a href="tel:2125551212">2125551212</a>

on Android will bring up the Phone app and pre-enter the digits for 2125551212 without autodialing.

Have a look to RFC3966

Solution 2 - Android

I have just written an app which can make a call from a web page - I don't know if this is any use to you, but I include anyway:

in your onCreate you'll need to use a webview and assign a WebViewClient, as below:

browser = (WebView) findViewById(R.id.webkit);
browser.setWebViewClient(new InternalWebViewClient());

then handle the click on a phone number like this:

private class InternalWebViewClient extends WebViewClient {

	@Override
	public boolean shouldOverrideUrlLoading(WebView view, String url) {
		 if (url.indexOf("tel:") > -1) {
			startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse(url)));
			return true;
		} else {
			return false;
		}
	}
}

Let me know if you need more pointers.

Solution 3 - Android

Generally on Android, if you simply display the phone number, and the user taps on it, it will pull it up in the dialer. So, you could simply do

For more information, call us at <b>416-555-1234</b>

When the user taps on the bold part, since it's formatted like a phone number, the dialer will pop up, and show 4165551234 in the phone number field. The user then just has to hit the call button.

You might be able to do

For more information, call us at <a href='tel:416-555-1234'>416-555-1234</a>

to cover both devices, but I'm not sure how well this would work. I'll give it a try shortly and let you know.

EDIT: I just gave this a try on my HTC Magic running a rooted Rogers 1.5 with SenseUI:

For more information, call us at <a href='tel:416-555-1234'>416-555-1234</a><br />
<br />
Call at <a href='tel:416-555-1234'>our number</a>
<br />
<br />
<a href='416-555-1234'>Blah</a>
<br />
<br />
For more info, call <b>416-555-1234</b>

The first one, surrounding with the link and printing the phone number, worked perfectly. Pulled up the dialer with the hyphens and all. The second, saying our number with the link, worked exactly the same. This means that using <a href='tel:xxx-xxx-xxxx'> should work across the board, but I wouldn't suggest taking my one test as conclusive.

Linking straight to the number did the expected: Tried to pull up the nonexistent file from the server.

The last one did as I mentioned above, and pulled up the dialer, but without the nice formatting hyphens.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionKevinView Question on Stackoverflow
Solution 1 - AndroidsystempuntooutView Answer on Stackoverflow
Solution 2 - AndroidMartynView Answer on Stackoverflow
Solution 3 - AndroidTarkaView Answer on Stackoverflow