Dialing phone number from Android Studio

0

I have put in Android Studio a web page with phone numbers and emails, the mail page has the code mailto: [email protected] and for the phone tel: 666666666, this page works independently, but at put it in Android Studio and create the apk, when you click on the number or the mail it shows an error message:

It is necessary to put another code in the web page so that when pressing on the number and the mail it shows us the telephone scoreboard or the manager of mail?

Table in htm

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>telefonos</title>
<style>
</style>
</head>

<body style="text-align: center">

<div class="rvps4">
<table width="567" border="1" cellpadding="2" cellspacing="2" style="border-spacing: 1.5pt; font-size: 14pt; font-family: 'Times New Roman', Times, serif; font-style: normal; font-weight: normal; color: #000000; text-decoration: none; margin: 0px auto">
	<tr valign="top">
		<td width="327" height="38" valign="middle" style="border-style: inset; padding: 1.5pt; background-color: #00ffff;" align="center">
		<p class="rvps3"><span class="rvts7">Nombre</span></td>
		<td width="117" height="38" valign="middle" style="border-style: inset; padding: 1.5pt; background-color: #ccffcc;" align="center">
		<p class="rvps3"><span class="rvts6">Telf.</span></td>
		<td width="97" height="38" valign="middle" style="border-style: inset; padding: 1.5pt; background-color: #ffff99;" align="center">
		<p class="rvps3"><span class="rvts6">Correo</span></td>
	</tr>
	<tr valign="top">
		<td width="327" height="33" valign="middle" style="border-style: inset; padding: 1.5pt; background-color: #ccffff;">
		<p class="rvps2"><span class="rvts9">xxxxx xxxxx xxxxx </span></td>
		<td width="117" height="33" valign="middle" style="border-style: inset; padding: 1.5pt; background-color: #ccffcc;">
		<p class="rvps3" align="center">
		<a class="rvts13" title="Exterior" href="tel:999999999">999999999</a></td>
		<td width="97" height="33" valign="middle" style="border-style: inset; padding: 1.5pt; background-color: #ffff99;">
		<p class="rvps3" align="center">
		<a class="rvts8" title="e-mail" href="mailto:[email protected]">
		e-mail</a></td>
	</tr>
</table>
</div>
</body>
</html>

And from android studio I show it with this code

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.rcf, container, false);

        webView = (WebView)view.findViewById(R.id.webview);
        webView.loadUrl("file:///android_asset/pagina.htm");

        WebSettings webSettings = webView.getSettings();
        webSettings.setJavaScriptEnabled(true);

        webView.setWebViewClient(new WebViewClient());

        return view;
    }

Thank you.

    
asked by SoCu 14.12.2017 в 17:21
source

1 answer

1

I hope this example helps you

public class MainActivity extends AppCompatActivity {

private WebView webView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.activity_main);

    webView = (WebView) findViewById(R.id.webView);
    WebSettings webSettings = webView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setRenderPriority(WebSettings.RenderPriority.HIGH);
    webView.loadUrl("http://www.mywebpage.com");
    webView.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if( URLUtil.isNetworkUrl(url) ) {
                return false;
            }

            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
            startActivity( intent );
            return true;
        }

    });
}

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (keyCode) {
            case KeyEvent.KEYCODE_BACK:
                if (webView.canGoBack()) {
                    webView.goBack();
                } else {
                    finish();
                }
            case KeyEvent.KEYCODE_MENU:
                webView.loadUrl("javascript:open_menu()");
            return true;
        }

    }
    return super.onKeyDown(keyCode, event);
}


}
    
answered by 21.12.2017 в 14:34