I've done more research, and I think I understand everything that's going
on.
Here is my WebViewClient:
public class MyWebViewClient extends WebViewClient {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
System.out.println("onPageStarted: " + url);
}
@Override
public boolean shouldOverrideUrlLoading(WebView webView, String url) {
System.out.println("shouldOverrideUrlLoading: " + url);
webView.loadUrl(url);
return true;
}
@Override
public void onPageFinished(WebView webView, String url) {
System.out.println("onPageFinished: " + url);
}
}
I have the following URL redirects from my server:
http://example.com/resource -> http://example.com/user-name/resource
http://example.com/logout.jsp -> http://example.com/login/logout
http://example.com/login/logout -> http://example.com/login
These URLs are part of a server that I don't control, so I just have to deal
with the behavior.
Here is the output from loading http://example.com/resource
onPageStarted: http://example.com/resource
onPageStarted: http://example.com/user-name/resource
shouldOverrideUrlLoading: http://example.com/user-name/resource
onPageFinished: hhttp://example.com/user-name/resource
# at this point, my WebView has blank content. I must wait until after the
second onPageFinished to grab my content.
onPageStarted: http://example.coms/user-name/resource
onPageFinished: http://example.com/user-name/resource
Here is the output from loading http://example.com/logout.jsp
onPageStarted: http://example.com/logout.jsp
onPageStarted: http://example.com/login/logout
shouldOverrideUrlLoading: http://example.com/login/logout
onPageFinished: http://example.com/login/logout
onPageStarted: http://example.com/login/logout
onPageStarted: http://example.com/login
shouldOverrideUrlLoading: http://example.com/login
onPageFinished: http://example.com/login
# again, at this point, my WebView has a blank page. I have to wait until
the 3rd onPageFinished to get my content from the WebView.
onPageStarted: http://example.com/login
onPageFinished: http://example.com/login
Based on the documentation, I don't expect this behavior. Notice that there
is an unbalanced number of onPageStarted's and onPageFinished's. I
especially dislike how onPageFinished gets called with my redirected URL,
yet the WebView doesn't contain my content. I understand that this behavior
is probably unchangeable, but this unexpected behavior should at least be
documented.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en