I'm writing an application which at start up posts a message to the server and waits for the response. To achieve this I'm using DefaultHttpClient.execute method with response time set to default. The whole operation is triggered as a separate thread which is set as a daemon thread, because I don't want for the application to be blocked when user decide to close it too fast (while still waiting for the server response). Still, when I try to kill an application through android.os.Process.killProcess call there is a significant delay, which I'm guessing is related with DefaultHttpClient.execute mechanism (not-daemon thread execution?). Is there a way to kill my connection just after killProcess call?
Asked
Active
Viewed 195 times
0
-
1Why are you trying to kill your process? That's really not a good thing to do. – Squonk Feb 09 '12 at 16:58
-
It is an action that is performed when you press the exit button. I know that it is not good practice, but knowing that and also knowing that most user prefer to have this button implemented in the game I'm obliged to perform that action. – Eric Feb 09 '12 at 17:05
-
If "most user prefer to have this button implemented in the game", then you have bugs in your app, such that ordinary approaches (e.g., pressing HOME) are causing those users some pain. Perhaps, rather than trying to kill your process, you should determine how to solve the problem of making your app behave better in the first place. – CommonsWare Feb 09 '12 at 17:45
-
ANSWER: Found perfect solution at (usage of AsyncTask combined with HttpPost.abort call): http://stackoverflow.com/questions/7007731/how-to-cancel-defaulhttpclient-execution-process-in-multithread – Eric Feb 09 '12 at 18:19
1 Answers
0
ANSWER: Found perfect solution at (usage of AsyncTask combined with HttpPost.abort call): How to cancel DefaulHttpClient execution process in multithread