我有以下示例:
private WebView wv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
wv = (WebView) findViewById(R.id.webView1);
wv.setWebViewClient(new TestWebViewClient());
String data;
try {
data = "<html><body><a href=\"http://test.com?param1=1¶m2=2¶m3=" + URLEncoder.encode("www.test.com?param4=4¶m5=5", "UTF-8")+ "¶m6=6\">Click</a></body></html>";
wv.loadData(data, "text/html", "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
private class TestWebViewClient extends WebViewClient{
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
System.out.println(url);
return super.shouldOverrideUrlLoading(view, url);
}
}
我在 shouldOverrideUrlLoading 中收到的 url 在某些设备上被解码。这是预期的行为?这可以在所有设备上重现吗?
谢谢