【发布时间】:2021-09-24 00:04:11
【问题描述】:
当用户点击电话号码字段时,我的 ANDROID 应用会拨打电话。 但是,在许多平板设备上,用户无法使用电话。
所以我需要像这样更改清单。
<uses-feature android:name="android.hardware.telephony" android:required="false" />
其实这个功能只是附加功能,并不是必须的。 因此,我希望用户在他们的平板设备上使用该应用程序。 并且我将避免在平板设备上拨打电话以避免错误。
我如何知道此设备是否可以拨打电话?
为了您的信息,我在我的应用程序中像这样在 webview 上拨打电话。它在手机设备上运行良好。
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
myWebView.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("tel:")) {
Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse(url));
startActivity(intent);
view.reload();
return true;
}
view.loadUrl(url);
return true;
}
});
【问题讨论】: