Make calls via an icon on the webwiew of the app [duplicate]

0

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

    
asked by anonymous 15.02.2018 / 03:32

1 answer

0

Add in 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.

    
15.02.2018 / 03:37