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 Build a Weather App (2015) Networking Making an HTTP GET Request with OkHttp

Slava Fleer
Slava Fleer
6,086 Points

I'm playing with the code and have some questions about url and Get. Would be appreciated for it =)

1st: I found that I could type http instead https w/o visible result. Is it so matter ?

2nd: if url string write wrong in this "api.forecast.io" we would not receive data, no any exceptions.

3rd: if instead http/s would be something else, there would be FATAL EXCEPTION: OkHttp Dispatcher that even generic Exception doesn't catch and app crashes.

other changes in url string after "https://api.forecast.io/" catching by "if(response.isSuccessful())".

So the main questions is : How to catch this fatal exception? And how to catch wrong url in when "api.forecast.io" wrote wrong ?

Thanks again to all answers.

Edit: Found one more interesting thing: while I'm running on Emulator, I don't need the Internet permission in manifest. But on device I do need it. Why emulator take it w/o permission? Is it a bug or done on purpose ?