0

First off all sorry for my english.. so I do not know if I know what I want to express correctly.. hope so:

If I run in a AsyncTask doInBackground in the following:

URLConnection conexion = url.openConnection();
conexion.setConnectTimeout (time_out);
conexion.connect ();

but before I cancel a asyntask Connection TIMEOUT exception continues until the timeout is there by way of indicating to cancel the task to stop trying to connect?

Regards

Edit: Code from the asyntask http://pastebin.com/G60jKJ0n

Peter
  • 21
  • 1
  • 4
  • you are saying that your connection time out happen before cancel it right ? – Sree Apr 03 '14 at 11:59
  • for example.. time_out=120000 miliseconds and i cancel at 20 seconds, the asyntask is canceled ok.. but.. conexion still try to connect – Peter Apr 03 '14 at 12:11
  • some tines this ill help http://stackoverflow.com/a/15631434 – Sree Apr 03 '14 at 12:13
  • http://omtlab.com/http-connection-timeout-in-android/] – Sree Apr 03 '14 at 12:13
  • but my problem, not is the time to take the connection, my problem is that when i cancel the asyntask, i want that "conexion" stop still trying to connect (off course only the user cancel the asyntask if he think that it take too much time), but conexion still at time_out – Peter Apr 03 '14 at 12:24
  • Add at my message, the code in a pastebin link. If the connection take too much, and the user cancel.. go to onCancelled, but connection still trying connect in doInBackground until it gives an exception. So there is any way, to dismiss the connection when go to onCancelled?. One more question.. why the exception is SocketTimeoutException and not ConnectTimeoutException? Thanks – Peter Apr 03 '14 at 21:06

0 Answers0