Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Jaime Lossada
3,721 PointsOkHttp cancel call enqueue???
I am using OkHttp like the video for WeatherApp recommended. But I discovered that if I tap several times in the refresh and I get a bad response from server the bad response message is show multiple times! I have been trying to figure out how to prevent that. I was trying with OkHttp.cancel(tag) but they still show the message. What would be the best way to stop the from running? Also if I move to another activity the call still keeps going I can see it on the log.
3 Answers
Luiz Carlos
15,714 PointsSee this link in documentation.
I hope this help you.
Jaime Lossada
3,721 PointsThanks, but I already read that. Is the tag just a normal Object?
Object tag = new Object();
Call call = RequestBuilder.tag(tag).build();
.....
OkHttpClient.cancel(tag)
Luiz Carlos
15,714 PointsYes.
How show in this link you call method "cancel" of the Class "Call"
Are you tried this?