Home > other >  Android Studio: Open every URL in WebView
Android Studio: Open every URL in WebView

Time:03-17

I want to turn a website into an app using the WebView. However, if I tap a link in the WebView, the app does not try to load the URL in the WebView, but in the browser (Chrome). How can I change this?

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

    WebView webView = (WebView) findViewById(R.id.webView);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.loadUrl("https://100315.fuxnoten.online/webinfo/account/");
}

CodePudding user response:

You can use setWebViewClient()

WebView webView = (WebView) findViewById(R.id.webView);
webView.setWebViewClient(new WebViewClient());
...
  • Related