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

Patrick Mayne
Patrick Mayne
12,979 Points

In the Build a weather app how can I set it to display Celsius as a default and not Fahrenheit?

I've just completed the weather app in the Beginner Android Development track and before I move onto the suggested topic of using location base API I want to understand how would amend the code to display Celsius and not Fahrenheit.

Any ideas?

1 Answer

To switch to SI units you've to add ?units=si to your URL so your url should be like this:

https://api.forecast.io/forecast/(apiKey)/37.8267,-122.423?units=si

And in code it should be like this:

String forecastUrl = "https://api.forecast.io/forecast/" + apiKey +
                "/" + latitude + "," + longitude + "?units=si";

Note that you can also change the language by adding the "lang" (language) keyword, like so: ?units=si&lang=en

Patrick Mayne
Patrick Mayne
12,979 Points

That worked wonders, you are a star! Thank you very much Tarek!