在Android&LT超链接;:使用电话4选择? [英] Using tel: Hyperlinks on Android < 4 alternative?
问题描述
我有一个应用这给普通座机号码英国08号。
I have an app which gives normal landline numbers for UK 08 numbers.
目前这是在应用中显示一个网页,当用户找到他们想要的,点击绿色的电话图标的数量。我用下面的JavaScript来强制再强制电话:链接的数量,弹出dailer
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
此方法适用罚款的所有更新的Android 4.0并尽可能我可以在上面看到。但是,当我用我的旧橙色旧金山手机(安卓2.3),它不把dailer。相反,它只是试图用电话翻开新的一页:01xxxxxxxx为这又显示网页无法使用邮件中的网址
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.
我想这是因为电话:HTML5是部分这就是为什么它不工作。是否有将在所有版本的任何替代方案?
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?
推荐答案
电话:
是preferred - 自20世纪90年代。 致电第一:
可用于某些设备更好地工作。另请参阅:如何加价的电话号码
tel:
is preferred - since the 1990's. callto:
may work better for some devices. See also: How to mark-up phone numbers?
修改
既然你有一个Android的WebView内运行的页面,可以处理此错误的黑客(也是在<一个描述href=\"http://stackoverflow.com/questions/4338305/android-webview-tel-links-show-web-page-not-found\">Android的WebView&QUOT;电话:&QUOT;链接显示的网页没有找到):
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>
这篇关于在Android&LT超链接;:使用电话4选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!