Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

Treehouse

Build a Weather App Course (How To)

via Treehouse

Overview

In this course, we will learn about a very common and important element of Android development: downloading data from the Internet! We will request weather forecast data from a free API provided by darksky.net. We will then parse that data (in JSON format) and display it in a single-page app. We will also see how to handle errors and situations when the network is unavailable.

What you'll learn

  • Networking
  • OkHttp
  • Using an API
  • Parsing JSON
  • Using a DialogFragment

Syllabus

Exploring an API

What is an API? What does it mean to use one? This stage will introduce the project and explore an API provided by darksky.net.

Chevron 6 steps
  • Introducing Stormy

    2:46

  • What's an API? What Does it Mean to Use One?

    6:45

  • The Dark Sky API

    4:09

  • What is an API?

    5 questions

  • Creating the Project

    2:23

  • Review: Dark Sky and Our Project

    5 questions

Networking

Even though we use the Web in a lot of ways in our daily lives, communicating with the Web and interacting with the information we get is not a trivial task. Let's see how to make networking in Android easy with the help of a 3rd party library called OkHttp.

Chevron 7 steps
  • How Do We Get Data from the Web?

    4:54

  • Networking on a Mobile Device

    1:45

  • Review: Networking Basics

    5 questions

  • Introducing OkHttp

    5:25

  • Getting the OkHttp Library Using Gradle

    4:54

  • Making an HTTP GET Request with OkHttp

    9:50

  • Review: Networking

    3 questions

Concurrency and Error Handling

Concurrency, or doing things together in parallel, is an important property of our system that let's us execute blocks of code simultaneously. In this stage, we take a look at what concurrency exactly means, why it's necessary, and how to make our networking call in a concurrent manner. We'll also learn how to gracefully handle any errors.

Chevron 7 steps
  • Keeping our App Fast with Asynchronous Processing

    4:51

  • Why Do We Use Asynchronous Processing?

    5 questions

  • Making Our Code Asynchronous

    7:00

  • Handling Errors

    7:21

  • Configuring the AlertDialog

    5:58

  • What To Do When the Network is Down

    9:08

  • What to Do When the Network is Down

    5 questions

Working with JSON

Our weather data is in the JSON format, which is a way of representing data in a simple-to-read manner that is easily parsed and used by programming languages. In this stage we will learn how to parse that data and store it in Java model objects that we can use in our app.

Chevron 9 steps
  • Exploring the Data

    4:27

  • Creating the Model

    1:48

  • Beautiful JSON

    4:41

  • Review: JSON

    5 questions

  • Introducing JSONObject

    7:27

  • Setting CurrentWeather from JSON

    5:14

  • Cleaning Up the Date and Time

    8:22

  • Setting the Weather Icon

    6:29

  • Review: Working with JSON

    5 questions

Building the Weather UI

With all the pieces in place, we can finally display our forecast data in an interface designed by one of our Treehouse designers.

Chevron 5 steps
  • Start at the Center

    7:08

  • One Cloudy Night

    5:16

  • The Foggy Bottom

    8:06

  • The Legal Side of APIs

    5:53

  • Review: Constraint Layout

    5 questions

Hooking Up the Model to the View

Our last task is to wire up the data from our CurrentWeather model to our freshly implemented user interface.

Chevron 6 steps
  • We're in a Bind

    6:28

  • Plugging in the Data

    10:11

  • Weather Icon

    4:36

  • I'm Feeling Refreshed

    7:22

  • That's a Wrap

    2:15

  • Review: Data Binding

    5 questions

Reviews

Start your review of Build a Weather App Course (How To)

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.