Search code examples
javajava-melwuitmidlet

How to use stoppable http connection using lwuit?


I want to have a http connection in my J2ME application using Lwuit which will have a timeout, can manually stop the request with a button, and a loading dialog while it is processing. I tried thread for HTTP connection but even when I try to interrupt the thread, the connection is still running.Can anyone help me with a example ?


Solution

  • There is no way to stop an HTTP connection in MIDP. LWUIT4IO provides an API to kill a connection via the kill method which effectively just discards the thread and closes the IO streams it is using. There is a timeout flag in MIDP but it doesn't always work and there is no indication of when the timeout should elapse.

    See LWUIT's see this, I don't have a sample of killing but there are several samples of using LWUIT4IO.