How to prevent WebView to open a browser when clicking on a link?

WebView opens fine but when clicking on any link opens the default browser.
How to make third-party links opened in my application?
package com.example.web;

import android.annotation.SuppressLint;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;



 public class MainActivity extends AppCompatActivity {

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

 WebView browser=(WebView)findViewById(R. id.web1);
browser.loadUrl("http://сайт.ком");
 WebSettings webSettings = browser.getSettings();
webSettings.setJavaScriptEnabled(true);

}
}
March 23rd 20 at 19:15
1 answer
March 23rd 20 at 19:17
Solution
I have figured out myself, here it is:
package com.example.webnure;

import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.os.Build;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.JavascriptInterface;
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;


public class MainActivity extends AppCompatActivity {

@SuppressLint("SetJavaScriptEnabled")
@Override
 protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
 WebView webView = new WebView(this);
setContentView(webView);
 webView.setWebViewClient(new WebViewClient());
webView.loadUrl("https://nure.ua/");

}

}


But now I have matured another question - how to add code to support JavaScript?

Find more questions by tags AndroidJava