黑莓的互联网问题

时间:2012-03-15 12:02:48

标签: blackberry

我正在开发一个黑莓应用程序,用于通过互联网发送消息。我已成功完成该项目,但现在我收到错误“即使网络连接可用,也要检查网络连接。

我已经关闭了我的http连接。但问题仍然存在。

有时它可以正常工作,但在somtime之后会抛出错误“。

总之,它没有获得互联网连接。

请帮帮我。

这是我的代码

InputStream in=null;
int rc=0;
HttpConnection http=null;
ConnectionFactory factory = new ConnectionFactory();
try{
String u="my url goes here";deviceside=true";
ConnectionDescriptor descriptor = factory.getConnection(u);
http = (HttpConnection)descriptor.getConnection();
in = http.openDataInputStream();
rc = http.getResponseCode();
if (rc != HttpConnection.HTTP_OK) {
    Dialog.inform("Please Check The Internet Connection ");
}
int ch;
while  ( (ch = in.read())!= -1){
    buff3.append( (char) ch);
}
Dialog.inform(" Your Balance Is \n " +buff3.toString() );
buff3.delete(0,buff3.toString().length());
//  buff3=new StringBuffer();
//stringItem.setText(" Your Balance Is \n " +buff.toString());
}
catch(Exception o){
    Dialog.inform("Please Check The Internet Connection ");
    buff3.delete(0,buff3.toString().length());
}
finally
{
    try {
        if(in != null)
        in.close();
            if(http != null)
             http.close();
           buff3.delete(0,buff3.toString().length());
    } catch (IOException ex) {
            ex.printStackTrace();
    }
}   

0 个答案:

没有答案