javaandroidwebwebviewandroid-webview

Android Web App - If the connection is successful for url1, else url2?


I have a webview android app. There are countries that block the main domain of the website. enter image description here And I have a secondary link to open in these networks - countries. note. Website blocking here, is not about malicious websites. Rather, some newspapers and websites do not contain any violations. I use java I need to use command

  String url1 = "htttps://domainone.com";
  String url2 = "htttps://domaintwo.com";
if 

url1 - connection is successful {

webview.loadUrl(url1);

}

else {
    webview.loadUrl(url2);
}
 

or If the error does not appear net::ERR_CONNECTION_RESET {


    webview.loadUrl(url1);

}

else {
webview.loadUrl(url2);
}

need code showing the method with thanks.


Solution

  • The problem has been resolved

            if (errorCode != WebViewClient.ERROR_HOST_LOOKUP
                    &&
           errorCode != WebViewClient.ERROR_CONNECT) {
                mWebView.loadUrl(Url1);
            } else {
    
                mWebView.loadUrl(Url2);
            }
    
    
    
    }