Поместите свой код в эту часть onLoadResource или PageStarted и добавьте webview.LoadUrl (youtURLs) Вот так
webView.setWebViewClient(new WebViewClient() {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
if (url.contains("website") && userAgent.contains(" Mobile Safari")) {
int index = userAgent.indexOf(" Mobile Safari");
if (index != -1) {
String fixedUserAgent = userAgent.substring(0, index);
webView.getSettings().setUserAgentString(fixedUserAgent);
webview.LoadUrl(youtURLs)
}
} else {
if (!userAgent.contains("MyBrowser")) {
String fixedUserAgent = userAgent + " Mobile Safari/537.36 MyBrowser/" + BuildConfig.VERSION_NAME + "a";
webView.getSettings().setUserAgentString(fixedUserAgent);
webview.LoadUrl(youtURLs)
}
}
}
@Override
public void onLoadResource(WebView view, String url) {
super.onLoadResource(view, url);
}
});