我试图通过GPRS(移动网络)在真实设备上建立URL的HttpConnection,但它不返回数据,但是我的同一代码通过无线运行良好,该代码在模拟器上也运行良好
我的代码是

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;
    }
}


注意:设备浏览器运行良好且BB服务已注册
多亏任何一位

最佳答案

我将我的评论移至以下答案:

在Blackberry中,设置wireless / gprs / 3g / simulator的连接网址非常具有挑战性,请按照以下指示进行操作


对于设备上的WiFi,请确保已在连接URL后缀";interface=wifi"
对于设备上的GPRS / 3G,请确保已为连接URL后缀BIS的";deviceside=false;connectionUID="和BES后缀的";deviceside=false"


可以在以下位置找到更多描述性的解释:


Need Clarification ---- Http Connection/GPRS
How to configure an IT Policy on the BlackBerry Enterprise Server to allow only the Internet Browser on the BlackBerry smartphone
Internet Connectivity (APN?)
Tag: APN
Different ways to make an HTTP or socket connection


编辑:链接5对OP很有用

10-08 13:04