Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,040 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