Disabling WebView links works on the emulator, but not on the device

I want to disable links to the page that I am loading into my WebView object. My code works fine on my emulator with api 25, but not on my phone with 23 api.

This is the code that blocks the links of my WebView:

public class NoLinksWebViewClient extends WebViewClient {

    @Override
    public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
        return true;
    }
}

I set my WebViewClient as an object of type NoLinksWebViewClient. It does the trick on an emulator, but not on my real phone.

How to solve this?

+6
source share
3 answers

My code works fine on my emulator with api 25, but not on my phone with 23 api.

, , API. WebViewClient, , , :

// since API 24
boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request)
// before API 24, now deprecated
boolean shouldOverrideUrlLoading(WebView view, String url)

, . , , , API 23 , API 24 , - ( ) .

, .

+9

: , . shouldOverrideUrlLoading (WebView view, String url) API 24, shouldOverrideUrlLoading ( WebView, WebResourceRequest) API 24.

 @SuppressWarnings("deprecation")
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        return true;
    }

    @TargetApi(Build.VERSION_CODES.N)
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
       return true;
    }

, .

+3

Is there an javafx.scene.Node.setDisable(boolean arg0)option? This way you can block items from

Documentation

-2
source

Source: https://habr.com/ru/post/1015530/


All Articles