开发者

Android - Stop HTTP request

开发者 https://www.devze.com 2023-04-11 17:29 出处:网络
How can I stop the request to the server ? ...I want to disconnect from the server once the user press cancel button.

How can I stop the request to the server ? ...I want to disconnect from the server once the user press cancel button. I u开发者_C百科sed .diconnect() method but the application get force close


Yes, we've hit the same issue. There doesn't seem to be a "clean" way to cancel a connection, so we just wrap ours up in try { ... } catch.

If you're playing in this area, you're also likely to discover that URLConnection doesn't timeout correctly either. This is a good description of the problem:

http://thushw.blogspot.com/2010/10/java-urlconnection-provides-no-fail.html

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号