Reputation: 14711
I am trying to access a.com, which in turn redirects me to b.com and loads it in the webview.
How do I just get the address that a.com redirects to without loading anything in the webview?
String postData = "session=" + session;
webView.postUrl(urlPassedFromArguments,
EncodingUtils.getBytes(postData, "base64"));
webView.setWebViewClient(new WebViewClient() {
@Override
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
if (isAdded() && getActivity() != null)
Toast.makeText(getActivity(), description,
Toast.LENGTH_SHORT).show();
}
@Override
public void onPageFinished(WebView view, String url) {
try {
dialog.dismiss();
} catch (Exception e) {
}
super.onPageFinished(view, url);
Logger.e("onPageFinished url", url);
if (!resolvedUrlLoaded) {
String postData = "token=" + token;
webView.postUrl(url,
EncodingUtils.getBytes(postData, "base64"));
resolvedUrlLoaded = true;
}
}
});
Upvotes: 0
Views: 1317
Reputation: 18243
@Override
public boolean shouldOverrideUrlLoading (WebView view, String url) {
// url to be loaded
return true|false;
}
Returns True if the host application wants to leave the current WebView and handle the url itself, otherwise return false.
Upvotes: 1