P
P
prrrrrrr2019-01-30 21:36:41
Java
prrrrrrr, 2019-01-30 21:36:41

How to open links in a webview application correctly?

There is a webview application that pulls up a specific url. But other links from this site open here, tell me how to open other links in a regular browser, not in the application.
MainActivity:

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        webView = (WebView) findViewById(R.id.webview);
        webView.setWebViewClient(new WebViewClient());
        webView.loadUrl("http://example.com");

        WebSettings webSettings = webView.getSettings();
        webSettings.setJavaScriptEnabled(true);
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oleg, 2019-01-30
@402d

I suggest. This is done by overriding the web client's
public boolean shouldOverrideUrlLoading (WebView view, WebResourceRequest request)
and depricated with the url as a string

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question