【发布时间】:2012-05-25 17:54:08
【问题描述】:
我在 Android ICS 上遇到了一个奇怪的问题,我有以下代码来建立读取 xml 文件的连接:
// 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被屏蔽了。您是否尝试在计算机上使用移动网络?
-
实际上我没有收到此错误,因为我没有使用带有 Android ICS 的 SG-SII,我的应用程序用户和 beta 测试人员向我报告了这个问题。
标签: android wifi android-4.0-ice-cream-sandwich 3g http-status-code-403