I used the code below to show my twitter login page.
For the first time, it calls public void onPageStarted----->public void onPageFinished(WebView view, String url) , and after logging in, it redirects the URL and calls public boolean shouldOverrideUrlLoading() . So the stream looks like this:
onPageStartedonPageFinishedshouldOverrideUrlLoading
But when I go to the second exit, I expect the same thread as above, but the thread has changed to:
onPageStartedshouldOverrideUrlLoadingonPageFinished
I did not understand why this has changed and why it calls shouldOverrideUrlLoading() , even if the URL is missing.
I printed the url webviews, it is null , but still why does it redirect this method.
private class TwitterWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { Log.d(TAG, "Redirecting URL " + url); if (url.startsWith(TwitterApp.CALLBACK_URL)) { mListener.onComplete(url); Log.e("starts","starts with"); TwitterDialog.this.dismiss(); return true; } else if (url.startsWith("authorize")) { Log.e("authorize","authorization"); return false; } return true; } @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { Log.d(TAG, "Page error: " + description); super.onReceivedError(view, errorCode, description, failingUrl); mListener.onError(description); TwitterDialog.this.dismiss(); } @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { Log.e("page started in",url); Log.d(TAG, "Loading URL: " + url); super.onPageStarted(view, url, favicon); mSpinner.show(); } @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); String title = mWebView.getTitle(); if (title != null && title.length() > 0) { Log.e("title","settitle"); mTitle.setText(title); } mSpinner.dismiss(); } }