Make calls through an icon on the website by the webwiew of the app

Asked

Viewed 39 times

0

How to make phone calls within webView. on the site has the link from the phone dial inside. Ex: when I open the site by the webview app I created it does not call the dial function from the phone. Someone who can help me?

1 answer

0

Add to Manifest:

<uses-permission android:name="android.permission.CALL_PHONE" />

In the code do:

ligar.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            if (ActivityCompat.checkSelfPermission(ligar.getContext(), Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) {
                return;
            }
            startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:"
                    + numerodotelefone)));
        }
    });

    TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    txtLi.append(tm.getSimOperatorName() + "\n");
    switch (tm.getPhoneType()) {
        case TelephonyManager.PHONE_TYPE_GSM:
            txtLi.append("GSM \n");
            break;
        case TelephonyManager.PHONE_TYPE_CDMA:
            txtLi.append("CDMA \n");
            break;
    }

The txtLi element is a textview that can be invisible, in the example I click on a button and then call the link by passing the phone number.

  • Here is a solution with the html https://answall.com/questions/45425/como-chamar-a-aplica%C3%A7%C3%A3o-de-ligar-n%C3%Bamero-em-uma-webview? Rq=1

  • Thank you Friend for answering my question. It hasn’t worked out yet but I’ll keep trying to use the code until I can put it in the right place. time I get come mark your reply as resolved and vote on your reputation. thanks.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.