Hi, I am writing an application which have network connection triggers server to send SMS or MMS to phone number input. However, when the phone number is the user's number, the MMS interrupted the connection with the connection hangs and cannot be closed, but SMS is ok.
The logic of the server (written by third party and cannot modify) is:
receive request -> (do something) -> send sms/mms to number input by calling sms/mms server (in queue) -> return response to the client with send result
The client is:
Create a HttpConnection -> if hc.getResponseCode() == OK, then get the InputStream / DataInputStream (I tried both) -> and ins.read() / ins.read(byte) / ins.read(byte, start, remain) / dis.readFully() (I tried all) -> close all connection and process the result
The situation is:
If the sms/mms server is not busy, the sms/mms may be delivered to the phone even earlier than the response (as I observed)
When a SMS is coming during the server waits the response, I observed that the GPRS connection icon "G" is changed, the device beeps for SMS coming, then "G" re-appear with correct response received from server.
But when a MMS is coming, the "G" is changed, beep, and "G" re-appear, but the connection hangs. I have tried to use a separate thread to act as the timer and try to close the connection, but nothing happens. The program just hanged when calling the blocking read() method or alternatives. I have tried 6610, 6100, 6230, and 6600 (using HTTP POST) with this problem appears..
My questions are:
1. Is there any way to prevent MMS hangs the device? Or resume the service?
2. How to detect the connection being interrupted by SMS / MMS? There is no exception throw, no pauseApp() and no hideNotify() called...
3. I failed to use separate thread to interrupt the connection, is there any way to do it? I have put hc and ins static, call hc.close() and ins.close() in separate thread but there is nothing happenss..
4. Is there any non-blocking method to process the stream?
5. Will this situation happens when being inturrupted by phone calls / go into a lift / etc.