2013-05-08 60 views
6

我如何更改WebView的內容類型PostUrl()? Android WebView中的

我想用PostData使用WebView#postUrl()。 但我無法找到改變請求的內容類型的方式。它總是「application/x-www-form-urlencoded」。

我該如何改變這種情況?

StringBuilder sb = new StringBuilder(); 
    sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); 
    sb.append("<resource>\r\n"); 
    sb.append("<element a=\"a\" b=\"b\"/>\r\n"); 
    sb.append("</resource>"); 
    String postData = sb.toString(); 

    mWebView.postUrl(url, postData.getBytes()); 

謝謝!

+0

你是否得到了這個答案 – png 2013-10-08 12:49:52

回答

0

WebView文檔看來,您似乎陷入了默認的content-type。我發現this有助於解析我的API端點中的數據,因爲我無法將content-type更改爲application/json或更容易消化的東西。