2013-09-30 77 views
-2

我在我的webview应用程序上有一个电话链接:tel:062123658但是当我点击它时..我找不到网页。在webview中打开电话链接

这是我的代码:

public class FullscreenActivity extends Activity { 

    private WebView webView; 

    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_fullscreen); 

     webView = (WebView) findViewById(R.id.webView); 
     webView.setWebViewClient(new myWebClient()); 
     webView.loadUrl("http://www.mywebsite.nl/"); 
     webView.setVerticalScrollBarEnabled(false); 
    } 

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

我怎么能解决这个问题?

Thanx。

+0

HTTP:/ /stackoverflow.com/a/4788521/1503130尝试此线程希望你得到你的答案 – Prateek

回答

0

我假设 “0621” 是一台海德堡前缀,因此作为一个实践问题,考虑与+49 621前缀......

试试这个:

Intent intent = new Intent(Intent.ACTION_CALL); 
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
intent.setData(Uri.parse(url)); 
startActivity(intent); 
+0

Thanx,它现在工作! –