3

I want to check if certain URL is finished loading, and then load another URL and if that new url is finished loading do something, how?

I know how to check if certain URL is finished loading like this:

webView.setWebViewClient(new WebViewClient() {

    public void onPageFinished(WebView view, String url) {
        // do stuff here
    }
    });

But what I want is:

 if url1 finished loading:
    load url2
    if url2 finished loading:
       //do some stuff here

How can I do this?

Amar Kalabić
  • 888
  • 4
  • 15
  • 33

2 Answers2

5

The url String parameter of onPageFinished always returns the actual URL loaded in the WebView.

You should do something like this:

webView.setWebViewClient(new WebViewClient() {

String urlA = "http://facebook.com";
String urlB = "http://facebook.com/friends";

public void onPageFinished(WebView view, String url) {
    if(url.equals(urlA)){
        //Do stuff if actual page url is urlA        
    }else if(url.equals(urlB)){
        //Do stuff is actual page url is urlB
    }
}
});
0

You need to load urls consecutively after the prior one loads completely.

the onProgressChanged() can be used. Please refer this SO answer, it is clear.

Community
  • 1
  • 1
BDRSuite
  • 1,594
  • 1
  • 10
  • 15