限制在android中的webview中拨打号码
我创建了一个 webview 。我已经使用 loadUrl() 加载了 URL。在 webview 中,有一些 9 和 10 数字。单击号码时,它将拨打电话,并且呼叫操作正在进行。但我想挂断电话。实际上这些数字包含超链接。因此,当我点击数字时,它应该重定向到相应的网址。 那么如何限制手机通话呢?
I have created a webview . I have loaded the URL by using the loadUrl(). In the webview , some 9 and 10 digits are there. While clicking on the numbers it will give a phone call and calling action is going on. But I want to stop the phone call. Actually these numbers contains hyperlinks. So when I click on number it should redirect to the corresponding url.
So what to do to restrict the phone call ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
:) 最重要的问题之一,也花了我相当长的时间,直到我意识到幕后的事情......
触摸浏览器!=桌面浏览器是课程,课程在事件中。
不完全是。 WebView 具有某些标准行为,即在某些事件上触发,在本例中,它看到触摸刚刚结束,可能是电话号码。 - 只需拨打即可。当浏览“经典”网页时,这可能是一个有用的功能,但在这里却不是。因此,让我们开始课程:
加载这样的测试页 http://www.snappymaria.com WebView 中的 /misc/TouchEventTest_v2.html。
注意正在发生的事件。
我现在不确定哪个是“顽皮事件”(基本上是浏览器在收到它时做了顽皮的事情),但我认为你至少需要“touchend”阻止“选择并调用”功能的触发。
在您的 HTML 应用程序中,您需要监听每个这样的事件
,然后您的处理程序就会执行。
您可能想尝试亲自尝试这些事件如何使 WebView 生效(因此您将通过调用
preventDefault()
来停止哪个事件。在我的 HTC Vision 2.3.3 上,我第一次感到惊讶的是我意识到手机还会生成“鼠标移动”事件以及触地和触摸移动......但随后禁用所有这些事件并尝试浏览为桌面设计的任何“正常”网页,并发现您无法再使用它。:) One of the top gotchas, took me also quite a while until i realised the behind the scenes-bits...
Touch browsers != desktop browsers is the curriculum, the lessons are in the events.
Not quite. The WebView has certain standard behaviour, that get's triggered on a certain events, in this case, it sees a touch just ended on a number that could be a tel.no. - and just dials it. When browsing the "classic" web, that might be a useful feature, here it isn't. So lets start the curriculum:
Load a testpage like this http://www.snappymaria.com/misc/TouchEventTest_v2.html in your WebView.
Notice the events happening.
I'm not sure now which one is the "naughty event" (basically it's the browser doing naughty things when it receives it), but i think you'll need at least "touchend" to stop that "select-and-call"-feature from firing.
In your HTML app, you will need to listen to each of those events like this
and then your handler goes s.th.
You might wanna try and experiment yourself how the events make the WebView tick (and which one you'll therefore stop by calling
preventDefault()
. On my HTC Vision with 2.3.3, i was first surprised when i realised the phone also generates "mousemove" events together with touchdown and touchmove... but then disable all those events and try browsing any "normal" webpage designed for desktop, and find that you cannot use it any more.