1

I am developing a blackberry app for sending messages through internet . i have succesfully completed the project, but now i am getting error "to check the net connection even if the net connection is available.

I have closed my http connection .but still the issue persist .

Sometimes it works alright but after somtime it throws the error ".

In one word it is not getting the internet connection .

Please help me.

this is my code

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();
    }
}   
V.J.
  • 9,492
  • 4
  • 33
  • 49
Shaikh Azhar Alam
  • 173
  • 1
  • 3
  • 16

0 Answers0