I am trying to download a zip file by using the following code;
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
This way, when using the interface=wifi;deviceside=true;, its working fine. This means I’ve to depend upon the WiFi network. But I want to download files using the 2G/3G link. For this, I tried the same code after removing the interface=wifi; connection parameter. But its throwing IOException: tunnel failed exception.
Please guide me about what do I’ve to do make it work on non-WiFi network.
I am developing in the following environment;
- BlackBerry JDE Eclipse Plugin 1.5.0
- BlackBerry OS 4.5
- BlackBerry Bold with a 3G card
Well, I had this problem before, I decided to do some processing to know the best connection type at a moment, here is the code I used:
http://www.localytics.com/blog/2009/how-to-reliably-establish-a-network-connection-on-any-blackberry-device/