Weather Forcasting App Project Report
Weather Forcasting App Project Report
Weather Forcasting App Project Report
BACHELOR OF TECHNOLOGY
IN
COMPUTER SCIENCE AND ENGINEERING
SUBMITTED BY
Name of Student University Roll No.
Saprem Aditya 19-B.CSE-225
CANDIDATE’S DECLARATION
I hereby certify that the project entitled WEATHER FORCASTING APP (USING ANDROID STUDIO)
submitted by SAPREM ADITYA 19-B.CSE-225 in partial fulfilment of the requirement for the
award of degree of the B.Tech (Computer Science & Engineering) submitted in Department of
Computer Science & Engineering at RIMT University, Mandi Gobindgarh is an authentic record
of my own work carried out during a period from July 2022 to Nov 2022. The matter presented
in this project has not formed the basis for the award of any other, diploma, fellowship or any
other similar titles.
CERTIFICATE
This is to certify that the project titled WEATHER FORCASTING APP (USING ANDROID STUDIO)
is the bonafide work carried out by SAPREM ADITYA 19-B.CSE-225 in partial fulfilment of the
requirement for the award of degree of B.Tech (Computer Science & Engineering) submitted in
Department of Computer Science & Engineering, at RIMT University , Mandi Govindgarh is an
aunthentic record of my own work carried out during a period from Jul 2022 to Nov 2022 under
the guidance of (Prof. Mr. Jasdeep Singh (Asst. Professor) Department of Computer Science &
Engineering). The Major Project Viva- Voice Examination has been held on 23-11-2022.
ABSTRACT
Weather forecasting is the application of science and technology to predict the state of the
atmosphere for a given location. Ancient weather forecasting methods usually relied on
observed patterns of events, also termed pattern recognition. For example, it might be
observed that if the sunset was particularly red, the following day often brought fair weather.
However not all of these predictions prove reliable.
Here this system will predict weather based on parameters such as temperature, humidity and
wind. User will enter current temperature; humidity and wind, System will take this parameter
and will predict weather (rainfall in inches) from previous data in database(dataset). The role of
the admin is to add previous weather data in database, so that system will calculate weather
(estimated rainfall in inches) based on these data. Weather forecasting system takes
parameters such as temperature, humidity, and wind and will forecast weather based on
previous record therefore this prediction will prove reliable. This system can be used in Air
Traffic, Marine, Agriculture, Forestry, Military, and Navy etc.
ACKNOWLWDGEMENT
I am thankful to Mr. JASDEEP SINGH for his support, co-operation and motivation provided to
me during the project development, for constant inspiration, presence and blessings.
I am extremely thankful to Dr. ASHISH OBEROI (HOD CSE Dept.), for valuable suggestion and
encouragement.
Lastly, I would like to thank the almighty and my parents for their moral support and my friends
with whom I shared my day-to-day experience and received lots of suggestions that improved
my quality of work.
Signature of Student
Saprem Aditya
23-11-2022
TABLE OF CONTENTS
1.1 OVERVIEW……………………………………………………………………….. 8
1.2 PROJECT AIM…………………………………………………………………… 9
CHAPTER 5 CONCLUSION……………………………………………………. 27
CHAPTER 6 REFERANCES…………………………………………………….. 28
LIST OF FIGURES
1. INTRODUCTION
Weather forecasting is the application of science and technology to predict the conditions of
the atmosphere for a given location and time. Weather forecasts are made by collecting
quantitative data about the current state of the atmosphere at a given place and using
meteorology to project how the atmosphere will change. The role of Technology has been
remarkable in the field of weather forecasting. Weather data is not only necessary for
researchers or scientists, ordinary people can be benefitted from it as well. People nowadays
are feeling the necessity of weather data as well. There are a variety of weather mobile apps in
Google Play and the App store. Those apps have great features and functionalities to satisfy
users. However, only a few of them have friendly user interface and human centered
interactions, which means that a lot of them might be difficult to be navigated even though
they provide enough functionalities. It is not convenient for new users. Therefore, we would
like to do improvements on weather mobile apps. It is basically for Apple smart phones and
tablets.
1.1 OVERVIEW
The project, the “WEATHER FORCASTING APP” is a cutting edge and versatile Weather
application fundamentally designed to help people to travel long distances connect with their
near place ones in a very friendly, easy and hassle-free manner. This application is compatible
with all the Android versions. And with said that, anyone owing their own android phone, the
Weather Report application can create a huge difference in hooking them up with others
provided, they also have the same application loaded on their device or PC. It is very simple to
use and easy to install that can be downloaded directly. When it comes to the features, they all
are extremely engaging and they keep updating periodically back to back. The extent of fun in
using this Weatherapplication is beyond comparison. This application is highly accommodative
for quick technological updates and integration. The application will have the features like
providing Forecast, Humidity, Pressure etc. It also provides Forecast Weather for 7 Days all
over the world.
In today’s busy routine life, the users of this Weather Report application will be just a click away
to access all the basic requirements in today’s day to day routine of the humans. The users will
have access to the latest Weather updates i.e. the burning Weather in all around the world.
Secondly, the users will have the access to the weather forecast before going out of their home
with the support of the GPS in their smart-phones. Compared to the other applications this
Weather Report application will prove to be an amazing user friendly application with lots of
more features.
2. IMPLEMENTATION
Android Studio is the official Integrated Development Environment (IDE) for android
application development. Android Studio provides more features that enhance our
productivity while building Android apps. Android Studio was announced on 16th May
2013 at the Google I/O conference as an official IDE for Android app development. It
started its early access preview from version 0.1 in May 2013. The first stable built version
was released in December 2014, starts from version 1.0.
Since 7th May 2019, Kotlin is Google's preferred language for Android application
development. Besides this, other programming languages are supported by Android
Studio.
• Android Studio has a consolidated environment where we can develop for all Android
devices.
• Apply changes to the resource code of our running app without restarting the app.
• It provides build-in supports for Google Cloud Platform. It makes it easy to integrate
Google Cloud Messaging and App Engine.
10
1. The toolbar provides us a wide range of actions, which includes running apps and
launching Android tools.
2. The navigation bar helps in navigating our project and open files for editing. It gives a
compact view of structure visible in the Project window.
3. The editor window is a space where we can create and modify our code. On the basis of
the current file type, the editor can change. While viewing a layout file, the editor displays
the Layout Editor.
4. The tool window bar runs around the outside the IDE window and contains buttons that
allow as to expand and collapse individual tool windows.
5. The tool windows provide us access specific tasks like search, project management,
version control, and more. We can able expand and collapse them.
6. The status bar displays the status of our project and IDE itself, as well as any messages or
warnings.
11
WHAT IS JAVA?
Java is a programming language and computing platform first released by Sun Microsystems in
1995. It has evolved from humble beginnings to power a large share of today’s digital world, by
providing the reliable platform upon which many services and applications are built. New,
innovative products and digital services designed for the future continue to rely on Java, as well.
While most modern Java applications combine the Java runtime and application together, there
are still many applications and even some websites that will not function unless you have a
desktop Java installed. Java.com, this website, is intended for consumers who may still require
Java for their desktop applications – specifically applications targeting Java 8. Developers as well
as users that would like to learn Java programming should visit the dev.java website instead and
business users should visit oracle.com/java for more information.
It is used for:
• Java works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc.)
• It is one of the most popular programming language in the world
• It has a large demand in the current job market
• It is easy to learn and simple to use
12
2.3 XML
What is XML?
Extensible Markup Language (XML) lets you define and store data in a shareable manner. XML
supports information exchange between computer systems such as websites, databases, and
third-party applications. Predefined rules make it easy to transmit data as XML files over any
network because the recipient can use those rules to read the data accurately and efficiently.
Extensible Markup Language (XML) is a markup language that provides rules to define any data.
Unlike other programming languages, XML cannot perform computing operations by itself.
Instead, any programming language or software can be implemented for structured data
management.
For example, consider a text document with comments on it. The comments might give
suggestions like these:
Such comments improve the document’s usability without affecting its content. Similarly, XML
uses markup symbols to provide more information about any data. Other software, like
browsers and data processing applications, use this information to process structured data
more efficiently.
13
XML TAGS
You use markup symbols, called tags in XML, to define data. For example, to represent data for
a bookstore, you can create tags such as <book>, <title>, and <author>. Your XML document for
a single book would have content like this:
<book>
</book>
Tags bring sophisticated data coding to integrate information flows across different systems.
When a company sells a good or service to another company, the two businesses need to
exchange information like cost, specifications, and delivery schedules. With Extensible Markup
Language (XML), they can share all the necessary information electronically and close complex
deals automatically, without any human intervention.
XML lets you transfer data along with the data’s description, preventing the loss of data
integrity. You can use this descriptive information to do the following:
Computer programs like search engines can sort and categorize XML files more efficiently and
precisely than other types of documents. For example, the word mark can be either a noun or a
verb. Based on XML tags, search engines can accurately categorize mark for relevant search
results. Thus, XML helps computers to interpret natural language more efficiently.
14
With XML, you can conveniently upgrade or modify your application design. Many technologies,
especially newer ones, come with built-in XML support. They can automatically read and
process XML data files so that you can make changes without having to reformat your entire
database.
APPLICATIONS OF XML
Data transfer
You can use XML to transfer data between two systems that store the same data in different
formats. For example, your website stores dates in MM/DD/YYYY format, but your accounting
system stores dates in DD/MM/YYYY format. You can transfer the data from the website to the
accounting system by using XML. Your developers can write code that automatically converts
the following:
Web applications
XML gives structure to the data that you see on webpages. Other website technologies, like
HTML, work with XML to present consistent and relevant data to website visitors. For example,
consider an e-commerce website that sells clothes. Instead of showing all clothes to all visitors,
15
the website uses XML to create customized webpages based on user preferences. It shows
products from specific brands by filtering the <brand> tag.
Documentation
You can use XML to specify the structural information of any technical document. Other
programs then process the document structure to present it flexibly. For example, there are
XML tags for a paragraph, an item in a numbered list, and a heading. Using these tags, other
types of software automatically prepare the document for uses such as printing and webpage
publication.
Data type
Many programming languages support XML as a data type. With this support, you can easily
write programs in other languages that work directly with XML files.
2.4 JSON
What is JSON?
• JSON stands for JavaScript Object Notation
• JSON is a lightweight data-interchange format
• JSON is plain text written in JavaScript object notation
• JSON is used to send data between computers
• JSON is language independent *
JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans
to read and write. It is easy for machines to parse and generate. It is based on a subset of the
JavaScript Programming Language Standard ECMA-262 3rd Edition - December 1999. JSON is a
text format that is completely language independent but uses conventions that are familiar to
programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python,
and many others. These properties make JSON an ideal data-interchange language.
16
2.5 API
APIs are mechanisms that enable two software components to communicate with each
other using a set of definitions and protocols. For example, the weather bureau’s software
system contains daily weather data. The weather app on your phone “talks” to this system
via APIs and shows you daily weather updates on your phone.
API stands for Application Programming Interface. In the context of APIs, the word
Application refers to any software with a distinct function. Interface can be thought of as a
contract of service between two applications. This contract defines how the two
communicate with each other using requests and responses. Their API documentation
contains information on how developers are to structure those requests and responses.
There are four different ways that APIs can work depending on when and why they were
created.
SOAP APIs
These APIs use Simple Object Access Protocol. Client and server exchange messages using
XML. This is a less flexible API that was more popular in the past.
RPC APIs
These APIs are called Remote Procedure Calls. The client completes a function (or
procedure) on the server, and the server sends the output back to the client.
Websocket APIs
Websocket API is another modern web API development that uses JSON objects to pass
17
data. A WebSocket API supports two-way communication between client apps and the
server. The server can send callback messages to connected clients, making it more efficient
than REST API.
REST APIs
These are the most popular and flexible APIs found on the web today. The client sends
requests to the server as data. The server uses this client input to start internal functions
and returns output data back to the client. Let’s look at REST APIs in more detail below.
18
3. PROJECT WORK
1. Open Android Studio and click on the file option on the upper left corner of the screen.
2. Click on the new option and select the wizard that you want and click on the next
option.
3. Now enter the details that are the name of the project, name of the package, and
android version.
4. Click on the finish option. (You will get two files MainActivity.java and activity_main.xml)
5. In the MainActivity.java write java code and in activity_main.xml file write code to
design front-end of the app.
19
To get the API key simply sign-in on WeatherBit and subscribe for a free API of Current
Weather Data API. After doing so you will receive an API key and you are good to go.
For this app to work we need to ask for three permissions from the system:
20
We will add a Button and TextView in the one and only screen of the application. When
the user will click the Button the temperature and city of that location will be shown in
the TextView.
In this step, we will get the last location of the device using Google Play Services –
• Setup google play services by downloading its components in the SDK manager.
• Add dependency in build.gradle for location –
“implementation com.google.android.gms:play-services-location:17.1.0″, the version
might change later.
• In the onCreate() method create an instance of the Fused Location Provider Client.
• After this use lastlocation() method to call the last location. See the Kotlin code
after Step 3.
To get JSON we need to use Volley Library to make an HTTP client request
Go to the MainActivity.kt file and refer to the following code. Below is the code for the
MainActivity.kt file.
21
3.3 CODE
To design the front-end of the application we write code in activity_main.xml and for
providing functionality to our application we write java code in MainActivity.java file.
We can even create more classes in the same package.
String response =
HttpRequest.excuteGet(“https://api.openweathermap.org/data/2.5/weatherq=”+CITY1+”&unit
s=metric&appid=73cbebdd0322acd49bda6ede059b2b18”);
https://home.openweathermap.org/users/sign_up
HttpRequest is the name of our class in the same package which we are using to fetch data.
JSONObject is the constructor used to convert external form JSON (Javascript Object Notation)
text into an internal form which we can retrieve with getRequest and can convert values into
JSON text using the toString method.
22
The SimpleDateFormat is used to set the format of the data which we want to display on the
TextView to be viewed on front end of our application.
Again we are setting data to the TextViews and setting the visibility of the TextViews used.
3.4 HTTPREQUEST.JAVA
First of all, we created the parameterized method executeGet in which targetUrl is the URL
we passed in our MainActivity class in response variable in which we passed our API key.
Then we opened the link and set our RequestMethod as “GET” as we want to fetch data.
Further, we are writing our code in the try-catch block so as to handle Exceptions. The
finally block is always executed whether an exception occurs or not.
Buffered Reader is class that is used to read text from character input stream buffering
characters so as to read characters efficiently.The method getResponseCode is used to
retrieve the response status from the server.
In finally block we are disconnecting the connection as finally block is always executed
whether Exception occurs or not.
For designing the front end of our application we can use two methods.
If we will drag the required field our XML code will be generated automatically.
While designing the front end we just need to specify the layout and id of the field rest all
are generally for the design purpose. In the textColor option “#000000” is the hashcode for
the black color.
Setting the layout is also important as layout determines the view of our front-end.
We can add as many attributes as we want. But in this tutorial, I only added the basic and
required attributes.
To add images as background we need to download the image and save it in the drawable
folder.
23
24
4.1 OUTPUT
• First of all, we will get the EditText with hint Enter City Name.
Figure 6. Output 1
• Then we will enter the name of the city and click the button Search Temp.erature.
• After clicking the button we will get the screen showing the required data.
25
Figure 7. OUTPUT 2
26
5. CONCLUSION
The development of a modern information society must be based on the application of new ICT
technologies. The use of smart mobile devices in all segments of society requires the
development of new mobile applications. The global software market in this area is growing at
a tremendous pace, so the need for education of IT specialists is very high. This trend of the
development of modern technologies enables the rapid development of the economy in the IT
sector. Of great importance is the advancement of the educational system, which must be
modular and dynamic, so that it can quickly implement new technologies into plans and
programs in all of the levels of education.
27
6. REFERANCES
FOR API: after creating account Log-In here to get the API
https://home.openweathermap.org/users/sign_in
https://www.codespeedy.com/weather-forecasting-android-app-using-openweathermap-api-
in-android-studio/
https://www.geeksforgeeks.org/how-to-build-a-weather-app-in-android/
28