English 中文(简体)
OS 5.0, 工作申请, 不在7. 0
原标题:Application working on OS 5.0, not in 7.0

我用OS5.0做了一个程序,对8520曲线的模拟器和装置也起作用。

现在,我正试图在 9900 上使用此应用程序, 有7. 0 版本, 它堆叠在设备中做一个 < code> HtpConnect 。 使用我的程序 5. 0 版本, 在 9900 模拟器中, 它可以正常工作 。 两个版本之间有什么区别吗? 我将我用来连接线索的代码放入线索中。 我不知道在哪里能找到这个问题的答案 。

try {
    mTimer = new Timer();
    mTimer.schedule(new CountDown(), 60000);
    UiApplication.getUiApplication().invokeLater(new Runnable() {
        public void run() {
            popup = new MyPopup("Cargando Incidentes...");
            UiApplication.getUiApplication().pushModalScreen(popup);
        }
    });

    conn = (HttpConnection) Connector.open(URL);

    InputStream contentIn = conn.openInputStream();
    byte[] data = new byte[400];
    int length = 0;
    StringBuffer raw = new StringBuffer();
    while (-1 != (length = contentIn.read(data))) {
        raw.append(new String(data, 0, length));
        str = raw.toString();
    }

    UiApplication.getUiApplication().invokeLater(new Runnable() {
        public void run() {
            try {
                conn.close();
                UiApplication.getUiApplication().invokeLater(new Runnable() {
                    public void run() {
                        try {
                            String datos[] = mainScreen.split(str, "ENDOFPAGE");
                            datos[0] = datos[0].substring(2, datos[0].length());
                            mainScreen.vecRegistro = mainScreen.split(datos[0],"$");
                            mainScreen.insertoEnBd();
                            mainScreen.insertoEnTablaDatosBD(_act);

                            UiApplication.getUiApplication().popScreen(popup);
                        } catch (Exception e) {
                            e.printStackTrace();
                            mainScreen.add(new RichTextField("Error ThreadIncidentes.run: "+ e.toString()));
                        }
                    }
                });
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    });
    return;
} catch (Exception e) {
}

private class CountDown extends TimerTask {
    public void run() {
        if (str.length() < 50){
            UiApplication.getUiApplication().invokeLater(new Runnable() {
                public void run() {
                    UiApplication.getUiApplication().popScreen(popup);
                    Dialog.alert("Error en la conexion");
                    System.exit(0);

                    clsThreadIncidentes.currentThread().interrupt();
                }
            });
            return;
        }
    }
}
问题回答

不要使用 connection.open 。 这是打开连接的遗留方式, 通常需要大量代码才能处理后缀, 取决于您通过 BIS、 MDS、 Wi-Fi 或 TCP 直接连接的 Wheter 。

从5.0开始, 您可以使用更新的网络 API。 这里引用的关键类是 < a href=" http://www. blakberry.com/ developers/docs/5. 0.0 api/index. html" rel="nofollow"\\ code > ConnectionFactory 。





相关问题
How does AlertListener work on Blackberry API 5.0?

Does the AlertListener interface works globally on all alerts on the blackberry device, or does it only work with alerts generated by your application? In other words, can I use this interface to ...

How to buffer audio in Blackberry?

I need to learn how to buffer audio stream from a remote server in Blackberry. There is a sample buffered playback app with Blackberry api but can you tell what url may I use to test the application?

Blackberry push notification implementation

How does one implement a push notification for a blackberry app? I heard that in order to do so I need to purchase a Blackberry Enterprise Server which costs me 1400 per year. Is this true? Where is ...

热门标签