1. Hook your app up to the OpenWeatherMap API
This repository provides you with some starter code that displays dummy forecast data in a RecyclerView. Your first task for this assignment is to write an AsyncTask to fetch forecast data from the OpenWeatherMap API and to display that data in the RecyclerView instead of the dummy data. You can find more info about the OpenWeatherMap API here: [url removed, login to view] Here are some steps you can follow to get everything working for this part of the assignment:
Sign up for an OpenWeatherMap API key here: [url removed, login to view] You'll need this to make calls to the API. If signing up for an API key is a problem for you, please contact me.
Write a utility method to construct a URL to query OpenWeatherMap's 5-day forecast API for a specified city name. You can read more about this API here: [url removed, login to view] Make sure you include your API key as a query string parameter in your URL.
Write a subclass of AsyncTask that uses a URL from the method you just wrote to get forecast data from OpenWeatherMap. Your AsyncTask should do the following things:
Display a ProgressBar in onPreExecute().
Fetch forecast data for a specified city as a JSON string in doInBackground(). For this assignment, you can hard code the name of a city for which to fetch data in your main activity class (e.g. "Corvallis, OR").
Hide the ProgressBar.
If for some reason you were unable to fetch forecast data in doInBackground(), display an error message.
If you successfully fetched forecast data, pass it into the ForecastAdapter using its updateForecastData() method to display the data in the RecyclerView.
Call your AsyncTask from your main activity class's onCreate() to make sure data is loaded when the app starts.
Write a utility method to parse the JSON data returned by OpenWeatherMap into an ArrayList of String objects, where each string in the list represents a forecast for one date/time entry in the JSON data. Specifically, each string should contain the following fields from one entry from list in the JSON data:
dt_txt - the date and time
[url removed, login to view] - the temperature (make sure you get the units right)
[url removed, login to view] - a general description of the weather
Don't worry too much about formatting your string super nicely (e.g. don't worry about converting UTC time into local time for now). For example, one of your weather strings might look like this:
2017-04-29 00:00:00 - Clear - 54F
Plug this parsing method into your AsyncTask to parse the JSON data before you pass it into the adapter.
2. Use an Intent to start a new activity
Once you have your app hooked up to the OpenWeatherMap API, implement functionality that allows the user to click on any item in the forecast list to view a "detailed" version of that forecast. Here are some steps you can follow for this part of the assignment:
Implement a new activity to represent the "detailed" view of the forecast. To do this, you should write:
A new layout XML file for this activity. At a minimum, this layout should contain a TextView you can use to display the weather string.
A new subclass of AppCompatActivity. At a minimum, this class should implement an onCreate() method that does the following:
Uses getIntent() to get the Intent that initiated the activity.
If the Intent was not null, grabs the forecast string extra from the Intent and displays it in the activity's TextView.
Add an entry in [url removed, login to view] for the new activity.
The app is currently set up to handle clicks on individual items in the forecast list by displaying a toast with the corresponding detailed forecast. Change this functionality so that a new explicit Intent is created to start the new activity you just implemented. When a forecast item is clicked, pass the the forecast string as an argument to the click handler and then into the Intent as an extra, and use the Intent to start the activity.
Đã trao cho:
12 freelancer đang chào giá trung bình $179 cho công việc này
Hello. how are you? i have full experience with android app development. i can build your app in a short time , i am sure i can do that wonderfully. give me chance.. Thanks.
**CHEAP APP DEVELOPMENT** I am a freelance app developer I specialize in android app development I am Java and Android certified. I have been doing software development for the past 5 years