Answer the question
In order to leave comments, you need to log in
Why does WebView and tel: link work crookedly?
Hello. There is an application on the minimum on webview. I assembled the frame on skethware, and then finished it on android studio. Piece of code:
webview2.setWebViewClient(new WebViewClient() {
@Override
public void onPageStarted(WebView _param1, String _param2, Bitmap _param3) {
if ((_param2.startsWith("https://wa.me/")) || (_param2.startsWith("https://vk.com/")) || (_param2.startsWith("https://instagram.com")) || (_param2.startsWith("https://www.facebook.com/")) || (_param2.startsWith("mailto:")) || (_param2.startsWith("viber://")) || (_param2.startsWith("https://www.gismeteo")) || (_param2.startsWith("https://t.me")) || (_param2.startsWith("https://twitter.com/")) || (_param2.startsWith("https://connect.ok.ru/")) || (_param2.startsWith("https://telegram.me/")) || (_param2.startsWith("https://api."))){
webview2.stopLoading();
intent1.setData(Uri.parse(_param2));
intent1.setAction(Intent.ACTION_VIEW);
webview2.goBack();
startActivity(intent1);
}
_fab.hide();
t = new TimerTask() {
@Override
public void run() {
runOnUiThread(new Runnable() {
@Override
public void run() {
webview2.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
webview2.getSettings().setJavaScriptEnabled(true);
webview2.getSettings().setSupportZoom(false);
}
});
}
};
if (_param2.startsWith("file:///android_asset/www/index.html")) {
webview2.clearHistory();
}
if (_param2.startsWith("tel:")) {
webview2.stopLoading();
intent1.setData(Uri.parse(_param2));
webview2.goBack();
intent1.setAction(Intent.ACTION_DIAL);
webview2.loadUrl(String.valueOf(getCacheDir()));
startActivity(intent1);
}
private class CustomWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView webView, String url) {
if(url.startsWith("tel:")) {
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse(url));
startActivity(intent);
return true;
}
return false;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question