Streams can be opened in several ways
1. HTTP communication:
Connection hc = Connector.open("http://www.wirelessdevnet.com");
2. Stream-based Socket communication:
Connection sc = Connector.open("socket://localhost:9000");
3. Datagram-based socket communication:
Connection dc = Connector.open("datagram://:9000");
4. Serial port communication:
Connection cc = Connector.open("comm:0;baudrate=9000");
5. File I/O
Connection fc = Connector.open("file://foo.dat");
I have used the HTTP communication.
HttpConnection c = (HttpConnection) Connector.open(url.getString());
this.responseCode = c.getResponseCode();
While running, I got a warning in the log says…
Warning: To avoid potential deadlock, operations that may block, such as networking,
should be performed in a different thread than the commandAction() handler.
In addition, the phone emulator is not responding for the alert 😦
mobiletest Midlet Suite wants to connect to http:///...... using airtime. This may result in charges.
Is it OK to use airtime?
No response for this alert when I press yes or no several times!
We need to write the HTTP connection in a separate thread, so that the main thread wont get blocked with it.