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

前端 未结 7 2076
隐瞒了意图╮
隐瞒了意图╮ 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 14:51

    According to the Retrofit 2.0 beta 3 changelog via link https://github.com/square/retrofit/releases/tag/parent-2.0.0-beta3

    New: isCanceled() method returns whether a Call has been canceled. Use this in onFailure to determine whether the callback was invoked from cancelation or actual transport failure.

    This should make stuff easier.

提交回复
热议问题