我可以在 Android 上通过 HTML 拨打电话吗?

发布于 2024-08-31 02:22:05 字数 290 浏览 11 评论 0原文

要在 iPhone 上通过 HTML 拨打电话,我创建了一个 标记,其 href 格式为:拨打我电话

Android 上有 HTML 的等效项吗?

澄清 - 使用格式 href='tele:123-555-1212' 确实适用于 Android。我正在设备上的本机 Java 包装器中测试该应用程序。我们似乎无法从本机包装器中托管的 Web 应用程序进行调用。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

情未る 2024-09-07 02:22:05

是的,你可以;它也适用于 Android

电话:电话号码
调用输入的
电话号码。有效的电话号码
IETF RFC 3966 中定义的是
公认。有效的例子包括
以下:

<前><代码>* 电话:2125551212
* 电话:(212) 555 1212

Android 浏览器使用电话应用程序来处理“tel”方案,如 RFC 3966 所定义。
在 Android 上单击类似以下的链接

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

将打开“电话”应用程序并预​​先输入 2125551212 的数字,而不会自动拨号。

查看 RFC3966

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

朮生 2024-09-07 02:22:05

我刚刚编写了一个可以从网页进行调用的应用程序 - 我不知道这对您是否有任何用处,但无论如何我都包括:

在您的 onCreate 中,您需要使用 webview 并分配 WebViewClient,如下:

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

然后像这样处理电话号码的点击:

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;
        }
    }
}

如果您需要更多指示,请告诉我。

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.

尝蛊 2024-09-07 02:22:05

一般来说,在 Android 上,如果您只是显示电话号码,然后用户点击它,它就会在拨号器中将其拉出。因此,您可以简单地执行以下操作:

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

当用户点击粗体部分时,由于其格式类似于电话号码,因此会弹出拨号器,并在电话号码字段中显示 4165551234 。然后用户只需按下呼叫按钮即可。

您也许可以

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

覆盖这两种设备,但我不确定这效果如何。我很快就会尝试一下并通知您。

编辑:
我刚刚在我的 HTC Magic 上尝试了一下,运行了 rooted Rogers 1.5 和 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>

第一个,周围有链接并打印了电话号码,工作得很好。拉出带有连字符和所有内容的拨号器。第二个,通过链接说出我们的号码,其工作原理完全相同。这意味着使用 应该可以全面工作,但我不建议将我的一次测试作为结论。

直接链接到该号码达到了预期目的:尝试从服务器中提取不存在的文件。

最后一个按照我上面提到的那样做了,并拉出了拨号器,但没有漂亮的格式化连字符。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文