Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to load URL in android Web View if HTTP or HTTPS not include in given URL

I have an project where I want to load some url came from webservice into a webView but. for that I am facing the following problem. Please help.

url = "www.facebook.com"
wv.loadUrl(url);

for above code I got an error say unable load webpage.

But if i changed this to

url = "https://www.facebook.com"

its working but I need to load url without having http or https mentioned .

Please help me on this.

like image 858
user3782810 Avatar asked Nov 20 '14 07:11

user3782810


1 Answers

add this by your own code like

    String urlCameFromServer = "www.facebook.com";
    if(!urlCameFromServer.contains("http")) {
         urlCameFromServer = "http://"+urlCameFromServer;
    }
    wv.loadUrl(urlCameFromServer);
like image 165
Abdul Mohsin Avatar answered Oct 29 '22 17:10

Abdul Mohsin