我正在从那里制作一个android网络视图,我想在单击URL tel:+917530000502时拨打特定的电话,但它不起作用。它显示ERR_UNKNOWN_URL_SCHEME _tel
。
我尝试了target=_blank
或_System
之类的所有方法,但对我来说不起作用。请帮助我解决此问题。我已允许我的应用进行通话。
private WebView webView;
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Log.e("Tag", "-->>>Not in the loop0");
if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.READ_PHONE_NUMBERS) == PackageManager.PERMISSION_GRANTED) {
Toast.makeText(MainActivity.this, "You already granted the permission", Toast.LENGTH_LONG).show();
webView = (WebView) findViewById(R.id.WebView1);
webView.setWebViewClient(new MyBroswer());
String url = "";
webView.getSettings().setLoadsImagesAutomatically(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
webView.loadUrl(url);
Log.e("Tag", "-->>>" + url);
} else {
requestcallpermission();
Log.e("Tag", "-->>>Not in the loop2");
webView = (WebView) findViewById(R.id.WebView1);
webView.setWebViewClient(new MyBroswer());
String url = "";
webView.getSettings().setLoadsImagesAutomatically(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
webView.loadUrl(url);
}
}
private class MyBroswer extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
private void requestcallpermission() {
Log.e("Tag", "-->>>Not in the loop2 in method");
if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CALL_PHONE)) {
new AlertDialog.Builder(this).setTitle("Permission Denied").setMessage("This permission is needed to Make phone calls").setPositiveButton(
"ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.CALL_PHONE}, CALLPHONECODE);
}
}
).setNegativeButton("cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int i) {
dialog.dismiss();
}
}).create().show();
} else {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CALL_PHONE}, CALLPHONECODE);
Log.e("Tag", "-->>>Not in the loop2 in else method");
}
}
我想通过android中的网络应用拨打电话。