I have a WebViewClient
attached to my WebView
like so:
webView.setWebViewClient(new MyWebViewClient());
Here is my implementation of MyWebViewClient
:
private class MyWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
webView.loadUrl(url);
return true;
}
}
I give the WebView
a URL to load via loadUrl()
. If I have a link (a href...
) in the page, my shouldOverrideUrlLoading
method is called and I can intercept the link click.
However, if I have a form whose method is POST
, the shouldOverrideUrlLoading
method is not called.
I noticed a similar issue here: http://code.google.com/p/android/issues/detail?id=9122 which seems to suggest overriding postUrl
in my WebView
. However, this API is only available starting from API level 5.
What can I do if I'm on API level 4? Is there any other way to intercept form posts?
This is known issue, that shouldOverrideUrlLoading
don't catch POST. See http://code.google.com/p/android/issues/detail?id=9122 for details.
Use GET! I personally tried using POST, because I expected some limitation of GET parameters (i.e. length of URL), but I just successfully passed 32000 bytes through GET locally without any problems.