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

Android

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

Synchronous vs Asynchronous GET Requests on Android

So, I've been enjoying learning a little bit about how to make HTTP Requests on Android.

I know Ben warned us we were going down to wrong path initially when it comes to making Get Requests and Synchronously and we'll have more lucky with Asynchronously. I understand why we did that but I'm curious as to why it doesn't work and where I'd have a better time making Synchronous get requests with HTTP?

I did some things with HTTP in the HTTP Basics course but unfortunately, my command line could never get requests to work properly (i.e. they'd connect but then disconnect before I could do anything with it. Thanks :)

1 Answer

Juan Pablo Lazcano
Juan Pablo Lazcano
11,267 Points

using Synchronous request is a good idea when your code runs in another Thread, or intent service, in that case, the synchronous will not block the main thread, so let say you need to upload or make a request in a specific order, you can use Synchronous request because you can be sure that one request is finish and then continue with another one