J'ai écrit une application BB simple qui fait une requête HTTP et télécharge des informations codées JSON. Lorsque je l'exécute sur l'émulateur avec le "; deviceSide = true" après l'URL, cela fonctionne correctement. Mais quand je l'ai essayé dans mon BlackBerry Storm appareil réel, je suis arrivé à l'exception suivante:BlackBerry java.io.IOException: Aucun tunnel à ouvrir
java.io.IOException: No tunnels to open
Voici le code que j'utilise pour faire la demande HTTP:
public static String doHttpRequest(String addr) {
HttpConnection hConn = null;
DataInputStream dis = null;
String strData = "";
try {
hConn = (HttpConnection)Connector.open(addr);
dis = new DataInputStream(hConn.openInputStream());
//Get the string in the stream
int c;
while ((c = dis.read()) != -1) {
strData = strData + (char) c;
}
}catch (Exception e) {
net.rim.device.api.ui.component.Dialog.alert(e.toString());
} finally {
try{
if(dis != null) dis.close();
if(hConn != null) hConn.close();
} catch(Exception e) {
net.rim.device.api.ui.component.Dialog.alert(e.toString());
}
}
return strData;
}
Ok merci. Je vais sur un autre téléphone que je sais avoir configuré correctement APN. – Edu