问题描述
我有一个 WebViewClient
贴在我的的WebView
像这样:
I have a WebViewClient
attached to my WebView
like so:
webView.setWebViewClient(new MyWebViewClient());
下面是我执行 MyWebViewClient
:
private class MyWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
webView.loadUrl(url);
return true;
}
}
我给的WebView
的URL通过使用loadURL给load()
。如果我在网页上的链接( A HREF ...
),我的 shouldOverrideUrlLoading
方法被调用,我可以拦截的链接点击。
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.
但是,如果我有他的方法是 POST
的 shouldOverrideUrlLoading
方法是不叫的形式。
However, if I have a form whose method is POST
, the shouldOverrideUrlLoading
method is not called.
我在这里看到一个类似的问题:的http:// code.google.com / P /安卓/问题/详细信息?ID = 9122 这似乎表明,在我的 postUrl >的WebView 。然而,这个API只能从API级别5起。
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.
我能做些什么,如果我在API级别4?有没有拦截表单提交的任何其他方式?
What can I do if I'm on API level 4? Is there any other way to intercept form posts?
推荐答案
这是众所周知的问题,即 shouldOverrideUrlLoading
没有赶上POST。请参见 HTTP://$c$c.google.com/ P /安卓/问题/详细信息?ID = 9122 了解详细信息。
This is known issue, that shouldOverrideUrlLoading
don't catch POST. See http://code.google.com/p/android/issues/detail?id=9122 for details.
使用GET!我使用POST亲自试过,因为我预计GET参数一定的局限性(网址即长度),但我成功地通过了32000个字节打通当地没有任何问题。
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.
这篇关于Android的 - 如何拦截在Android中WebViewClient表单POST的API级别4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!