i developed an application that access the web through the mobile application using j2me for nokia cellphones but when i tried to run this application on blackberry devices i got a problem with it, no website want to be opened, it just freezes so can anyone help me pls cos i could not find any solution for it these r the lines of code that i'm using in the application
this line i'm using to read something from web
hc = (HttpConnection) Connector.open(url); dis = hc.openDataInputStream();
int dataleft = dis.available();
for (int j = 0; j < dataleft; j++) {
buffer.append((char) dis.read());
}
dis.close();
hc.close();
and this line to open a website
this.platformRequest("http://stackoverflow.com/questions");
You're probably running that code (which has some issues... don't depend on available() to be accurate, you should just call read() until it returns -1) on the event thread, which is a big no-no on the BlackBerry. The app is likely trying to prompt the user for permission to make the HTTP request, but since the even thread is blocked it can't do it. There's a pretty good description of what to do and not do on the BlackBerry event thread here:
http://www.thinkingblackberry.com/archives/182
It's also mentioned in the API documentation for HttpConnection:
This interface performs blocking Input and Output operations. An application will lock if an implementation of this interface opens a connection from within the main event thread. Prevent an application from locking by opening a connection from within a thread that is separate from the main event thread.
The API docs are at:
http://www.blackberry.com/developers/docs/4.5.0api/javax/microedition/io/HttpConnection.html