I tried to make HttpConnection of URL through GPRS (Mobile network) on real device but it doesn’t return data, but I the same code working well through wireliess, the code also working well on simulator
My code is
public static String getHttpUTFResponse(String url) {
HttpConnection connection = null;
byte responseData[] = null;
try {
connection = (HttpConnection) new ConnectionFactory()
.getConnection(url).getConnection();
int len = (int) connection.getLength();
System.out.println(len);
if (len != -1) {
responseData = new byte[len];
DataInputStream dis;
dis = new DataInputStream(connection.openInputStream());
dis.readFully(responseData);
dis.close();
}
} catch (IOException e) {
System.out.println("Connection Error");
} finally {
if (connection != null) {
try {
connection.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
connection = null;
}
}
if (responseData != null) {
try {
return new String(responseData,"UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return null;
}
} else {
return null;
}
}
Note: the device browser working well and BB service was registered
Thanks to any one
I am moving my comments to these answer:
In Blackberry setting up the connection url for
wireless / gprs / 3g / simulatoris pretty challenging, please follow the below pointersWiFion device, make sure you have suffixed";interface=wifi"to the connection urlGPRS / 3Gon device, make sure you have suffixed";deviceside=false;connectionUID="for BIS and";deviceside=false"for BES to the connection URLMore descriptive explanation can be found at:
EDIT: Link 5 was useful for OP