0

Right now I have a webview being loaded, and then after it's loaded, I have a Runnable started with a while loop inside of it - I want to monitor the URL in the webview for changes. However, url can't be resolved inside the Runnable:

mWebview.setWebViewClient(new WebViewClient() {

    @Override
    public void onPageFinished(WebView view, String url) {
        super.onPageFinished(view, url);
        mWebview.scrollTo(681, 100);
    }
});

//BREAK 

new Thread(new Runnable() {
    public void run() {
        while(url.contains("displaylogin")) {

Is there any way to monitor an element in the UI thread with a Runnable? Or am I going about this the wrong way, and there's a better way to continuously monitor the URL for changes?

Einar
  • 1,001
  • 3
  • 11
  • 28
IAmTheSquidward
  • 562
  • 6
  • 22
  • I found this thread: [How to “Monitor” the URL base in WebView](http://stackoverflow.com/questions/15937907/how-to-monitorthe-url-base-in-webview), but the `if else` statement only checks once, and then quits. – IAmTheSquidward Jun 13 '14 at 20:21
  • You don't need a Runnable. All you need to do is override the shouldOverrideUrlLoading and inspect the URL and return true or false based on what your condition. – Raghu Jun 13 '14 at 20:38

0 Answers0