我在Android ICS得到一個奇怪的問題,我有以下代碼囑咐連接讀取XML文件:的Android ICS連接獲得403響應,但確定通過Wifi
// previous code......
URL url = new URL("https://urltomyxmlfile.com/xmlfile");
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
XML_handler myXML_handler = new XML_handler();
xr.setContentHandler(myXML_handler);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setConnectTimeout(5000);
connection.setReadTimeout(25000);
connection.setDoInput(true);
connection.connect();
InputStream input = connection.getInputStream();
xr.parse(new InputSource(input));
//more code....
此代碼適用於所有Android版本,無論是WiFi和3G,但在Android ICS只適用於WiFi,在3G連接我得到403響應。
我無法確定此問題的來源,我沒有正確配置連接? Android ICS有沒有新的限制? https問題?
額外的信息:這個代碼是不是在UI線程運行
感謝您的幫助!
新的額外信息:我發現只有三星Galaxy SII的用戶遇到了這個問題。
也許您的移動網絡IP網關被阻止。您是否嘗試在計算機上使用移動網絡? – rekire
其實我沒有收到這個錯誤,因爲我沒有在Android ICS上使用SG-SII,我的應用程序用戶和beta測試人員都在向我報告問題。 –