// Set the web view client
main_webview.setWebViewClient(new WebViewClient() {
// For api level bellow 24
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url.startsWith("http")) {
// Return false means, web view will handle the link
return false;
} else if (url.startsWith("tel:")) {
// Handle the tel: link
handleTelLink(url);
// Return true means, leave the current web view and handle the url itself
return true;
}
return false;
}
// From api level 24
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
// Get the tel: url
String url = request.getUrl().toString();
if (url.startsWith("http")) {
// Return false means, web view will handle the link
return false;
} else if (url.startsWith("tel:")) {
// Handle the tel: link
handleTelLink(url);
// Return true means, leave the current web view and handle the url itself
return true;
}
return false;
}
});
api level 24 이상은 shouldOverrideUrlLoading(WebView view, WebResourceRequest request)
미만은 shouldOverrideUrlLoading(WebView view, String url)
사용
반응형
'코딩쟁이 > android' 카테고리의 다른 글
[안드로이드] 비콘(beacon) 스캔 테스트 (10) | 2019.11.27 |
---|---|
[안드로이드] 오레오 대응 Notification Channel, FCM삽질기 (0) | 2019.11.07 |
[안드로이드]FCM 푸시울릴때 화면깨우기. (0) | 2019.10.08 |