机器人的WebView"联系电话:"链接显示找不到网页 [英] Android WebView "tel:" links show web page not found
问题描述
我试图让我的Android的WebView应用程序打开电话:链接到手机上。每次我打开了它的伟大工程,并开辟了手机的电话联系。然而,一旦我做了我的电话,返回到该应用程序是在一个网页,上面写着网页找不到电话:0000000000。然后我打后退按钮一次去,我点击电话号码的网页。
I am trying to get my android webview app to open tel: links to the phone. Every time I open up a telephone link it works great and opens up the phone. However once I am done with my call and go back to the app it is at a page that says "Web Page Not Found tel:0000000000". Then I have to hit the back button once more to get to the page that I clicked the telephone number on.
有没有办法得到它打开电话的链接,而不试图找到在web视图页面,以及在手机上打开它?
Is there a way to get it to open the TEL link without trying to find the page in webview as well as opening it up on the phone?
这是code我正在使用的WebView覆盖TEL其处理和邮寄地址链接:
This is code I am using in WebView to override its handling of the TEL and Mailto links:
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("mailto:") || url.startsWith("tel:")) {
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse(url));
startActivity(intent);
}
view.loadUrl(url);
return true;
}
任何帮助将是AP preciated。我花了2小时以来淘goodle并没有产生任何答案。
Any help would be appreciated. I have spent the last 2 hours scouring goodle and have failed to produce any answers.
推荐答案
行,所以我解决,我认为这个问题。我只是需要单独的URL重写如下:
OK so I solved the issue I think. I just needed to separate the URL overrides as follows:
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;
}
现在我的正常环节的工作还有电话联系。我还可以添加在那里GEO:联系,如果我需要,它不会给我说,我面前打开的地图在手机上的问题
Now my regular links work as well as the tel links. I can also add in there for geo: links if I need to and it will not give me the issue that I was having before to open up maps on the phone.
这篇关于机器人的WebView"联系电话:"链接显示找不到网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!