文件下载在BlackBerry上的非WiFi网络上不起作用
我正在尝试使用以下代码下载一个zip文件文件下载在BlackBerry上的非WiFi网络上不起作用,blackberry,download,blackberry-eclipse-plugin,Blackberry,Download,Blackberry Eclipse Plugin,我正在尝试使用以下代码下载一个zip文件 HttpConnection httpConn = null; InputStream inStream = null; int responseCode = 0; String connParams = " ;interface=wifi;deviceside=true;"; httpConn = (HttpConnection) Connector.open(src + connParams); responseCode = httpConn.
HttpConnection httpConn = null;
InputStream inStream = null;
int responseCode = 0;
String connParams = " ;interface=wifi;deviceside=true;";
httpConn = (HttpConnection) Connector.open(src + connParams);
responseCode = httpConn.getResponseCode();
if (responseCode != HttpConnection.HTTP_OK) {
throw new IOException("Response: " + responseCode);
}
// Other relevant code
这样,当使用接口=wifi时;deviceside=true代码>,工作正常。这意味着我必须依赖WiFi网络。但是我想使用2G/3G链接下载文件。为此,我在删除interface=wifi后尝试了相同的代码代码>连接参数。但是它抛出了IOException:tunnel失败了exception
请指导我如何在非WiFi网络上工作
我在以下环境中发展
- BlackBerry JDE Eclipse插件1.5.0
- 黑莓操作系统4.5
- 黑莓黑体手机配3G卡
在BlackBerry 4.5上,您仍然需要担心在连接字符串的末尾添加后缀
interface=wifi;deviceside=true;
如果您只想使用Wi-Fi连接,则为有效的连接字符串后缀。有关支持BlackBerry支持的许多其他类型传输的更多信息,请参见我的(2)答案。在一个答案中,我指给你黑莓网站上的链接
在另一个答案中,我发布了一些示例代码,其中包含选择传输的算法,并为该传输创建连接字符串后缀。请参阅getWifiConnection()
,getBesConnection()
,getSimConnection()
等方法,以获取正确后缀的示例。好吧,我以前遇到过这个问题,我决定进行一些处理,以了解最佳连接类型,下面是我使用的代码:
请参考已尝试过的。结果相同;例外。