url在WebViewClient.shouldOverrideUrlLoading中解码(WebView视图,String url)

时间:2013-06-03 15:25:55

标签: android android-webview webviewclient

我有以下示例:

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&param2=2&param3=" + URLEncoder.encode("www.test.com?param4=4&param5=5", "UTF-8")+ "&param6=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在某些设备上被解码。 这是一个预期的行为?这可以在所有设备上重现吗?

由于

0 个答案:

没有答案