Opening a URL connection in your mobile phone

Streams can be opened in several ways

1. HTTP communication:

Connection hc ="");

2. Stream-based Socket communication:

Connection sc ="socket://localhost:9000");

3. Datagram-based socket communication:

Connection dc ="datagram://:9000");

4. Serial port communication:

Connection cc ="comm:0;baudrate=9000");

5. File I/O

Connection fc ="file://foo.dat");

I have used the HTTP communication.

HttpConnection c = (HttpConnection);
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.