2012-02-23 20 views
6

En mi aplicación, estoy abriendo la url usando webview. Esta url abre la página que contiene algunos números de teléfono. Ahora quiero hacer una llamada telefónica sin abrir el marcador del teléfono si haces clic en el número de teléfono. ¿Es posible? Por favor Alguien puede ayudarme.android - Cómo hacer una llamada desde webview

gracias

Respuesta

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

Gracias JackTurky! Aquí hay un poco más, para mostrar cómo se ajusta con webView:

webView.setWebViewClient(new WebViewClient() { 
     public boolean shouldOverrideUrlLoading(WebView view, String url) { 
      if (url.startsWith("tel:")) { 
        Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(url)); 
        startActivity(intent); 
        return true; 
      } 
      return false; 
     }   
    }); 
Cuestiones relacionadas