Using Square's Retrofit Client, is it possible to cancel an in progress request? If so how?

前端 未结 7 2025
隐瞒了意图╮
隐瞒了意图╮ 2020-12-25 14:07

I\'m using Square\'s Retrofit Client to make short-lived json requests from an Android App. Is there a way to cancel a request? If so, how?

相关标签:
7条回答
  • 2020-12-25 15:11

    Wrap the callback in a delegate object that implements Callback as well. Call some method to clear out the delegate and have it just no-op whenever it gets a response.

    Look at the following discussion

    https://plus.google.com/107765816683139331166/posts/CBUQgzWzQjS

    Better strategy would be canceling the callback execution

    https://stackoverflow.com/a/23271559/1446469

    0 讨论(0)
提交回复
热议问题