3. Step 1: Create a basic android application. ...
Step 2: Create a welcome slider. ...
Step 3: Create the basic Main Page UI. ...
Step 4: Create a Weather API key using Open Weather
Map. ...
Step 4: Call the weather API. ...
Step 5: Display the data in online and offline mode.
4. The application is a basic weather app which displays
basic weather information depending on the users
location.
5. You can create any custom welcome slider that you
like. We have chosen Material Intro Slider for this
project. In our custom welcome slider we just ask the
users name and user the greet the user later on. In the
second custom slider greet the user depending on the
time of the day and similarly display an image or
AM/PM accordingly.
6. we have created a basic UI that look like cards and
each card displays current location weather
information.
7. You first need to Sign Up before you can generate an
API key for your Weather API. After signing up
navigate to the API section of the website and select
the automatically generated weather API key. Save this
API key as you will need this to call from you app.
8. We have used Retrofit for a type safe HTTP client call.
For calling the weather API we need the base URL of
the and the user’s coordinates are parameters.
9. Please do refer this blog if you want any more information
about Retrofit. We have selected the current weather data >
geographic coordinates as we need basic information.
Now we need to get the users current location coordinates
and then use our API key to call the API. We need to ask a
run time permission for location for Android M and above.
We can get the users coordinates by using GPSTracker.
We need to call the API by passing the required parameters
like latitude, longitude, units and the API key.
The data which we get back from the API can be used to
display in the UI and store in the local database (SQLite)
for when the user is offline. We get the data back in the
JSON format and we have to convert this to local plain old
java objects (POJO) to access the
10. You can use the above the JSON code and convert it into POJO classes
using jsonschema2pojo.
First we have to get the data by the help of retrofit in-build methods
and then save the data into our local SQLite database if its not present
or we can directly extract the data to display in the UI.
Now we can create a table for storing the required data from the JSON
API data.
Now we have data to display in the UI when the user is Online or
Offline. We just use the data and display it on the UI by attaching the
data to the corresponding TextView.
Please do refer this document to store your API key securely in the app.
We have also added a help section which is a Showcase view.
Refer the entire source code for this project or Download from the
Google Play and please do change with your local API key.
11. The Weather App is a simple project developed using
JavaScript, CSS, and HTML. This project is an
interesting project for simply weather forecasting. The
user can check the condition of the present-day
climate probability and predict whether the day is a
cloudy or sunny day. The user can write down the
name of any city across the world in the app