You are on page 1of 16

P K TECHNICAL CAMPUS, CHAKAN

A MICRO-PROJECT REPORT ON
“WEATHER APPLICATION”

SUBMITED BY:-
GAIKWAD ATUL SUBHASH

ENROLLMENT NO:-
2216620153

UNDER GUIDANCE OF
Prof. mrs. SHRADDHA PARDESHI MA’AM
THIS IS CERTIFY THAT THE MICROPROJECT
IS SUCCESSFULLY SUBMITTED BY,

• Gaikwad ATUL SUBHASH

MRS. SHRADDHA HEAD OF THE


PARDESHI MA’AM DEPARTMENT
ACKNOWLEDGEMENT
In the accomplishment of this micro-project successfully,
many people have best owned upon me their blessings and
heart-privileged support. Primarily, I would like to express a
special thanks of gratitude to the Principal Sir of the P.K.
Technical Campus for giving this golden opportunity with all
the required facilities for completing this micro project of
mine.

I would like to extend my gratitude to our MAD subject


teacher, Prof. Shraddha Pardeshi madam, whose valuable
guidance has been the ones that helped us patch this project
and make it full proof success. Their suggestions and
instructions has served as the major contributor towards the
completion of the micro-project. suggestions and provided
the required resources needed for the micro -project. I
would also like to thank my parents who have helped with
their valuable time.

3
ABSTRACT
As a student enrolled in the P. K. Technical Campus, Chakan,
every semester we require to do a micro-project on any one topic in
the syllabus of the respective subjects. Hence, we have created a
project on Weather Application as the micro-project for the subject
MAD (22617).

The development of a weather application for Android is based on


several fundamental components. It begins with integrating data from
reputable sources to ensure the availability of accurate weather
information. Leveraging the device's GPS capabilities enables location-
based services, providing users with personalized weather forecasts
based on their current location. A user-friendly interface is crucial,
emphasizing usability and intuitive navigation.

Weather data is presented clearly using graphical representations


and textual descriptions for enhanced comprehension. The application
includes notification features to keep users informed about significant
weather events or changes. Customization options allow users to tailor
settings according to their preferences, including units of measurement
and notification preferences.

Accessibility features ensure inclusivity for all users, while


localization in multiple languages enhances usability worldwide. By
adhering to these principles, the Android weather application aims to
deliver a comprehensive solution, prioritizing user experience and
informed decision-making based on weather conditions.

4
INDEX
Sr. No. Title Page
No.

1. Acknowledgement 3

2. Abstract 4

3. Introduction 6

4. Scope, Significance and Requirements 7

5. Program Code 8-12

6. Output 13

7. Conclusion 14

8. References 15

5
Introduction
Weather forecasting is the application of science and
technology to predict the conditions of the atmosphere for a
given location and time. Human beings have attempted to
predict the weather informally for millennia and formally
since the 19th century.
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.
There are a variety of end uses to weather forecasts. Weather
warnings are important forecasts because they are used to
protect life and property. Forecasts based on temperature and
precipitation are important to agriculture, and therefore to
traders within commodity markets. Temperature forecasts are
used by utility companies to estimate demand over coming
days. On an everyday basis, people use weather forecasts to
determine what to wear on a given day. Since outdoor
activities are severely curtailed by heavy rain, snow and wind
chill, forecasts can be used to plan activities around these
events, and to plan ahead and survive them. In 2009, the US
spent $5.1 billion on weather forecasting.

 SIGNIFICANCE OF PROJECT –
The main significance of this micro-project is to understand
how an android application is built, perform operations in the
database, use Recycler View to show list of items and use
Alarm Manager and Broadcast Receiver to show reminder
notifications.
6
 SCOPE OF PROJECT –

The weather application micro project focuses on developing a


user-friendly digital tool to provide individuals with easy access to
accurate weather forecasts. Beginning with meticulous interface
design, the project emphasizes simplicity and clarity to ensure
intuitive navigation for users. Technical implementation involves
integrating weather APIs for data retrieval, enabling the application
to fetch and process weather information efficiently. Tailoring
forecasts to users' locations enhances relevance, achieved through
geolocation services or manual input. Visualization techniques,
including charts and graphs, present weather data comprehensively,
empowering users to make informed decisions. Additionally, the
application offers customizable features such as notification
preferences and language settings for enhanced user experience.
Thorough testing and documentation ensure reliability and
accessibility across various devices, cementing the project's goal of
delivering reliable weather updates seamlessly.

 HARDWARE REQUIREMENTS –
1. Laptop or PC with minimum 8GB RAM and i5/i7 8th Gen
processor.

 SOFTWARE REQUIREMENTS –
1. Operating System - Windows 11
2. Android Studio Electric Eel 2022.1.1
3. Android Emulator – Small Phone API(Android 13)

7
PROGRAM CODE
activitymain.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".MainActivity" android:background="#e8f4f8"
android:orientation="vertical" android:padding="16dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textSize="40sp"
android:text="Weather Update"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</View>

<EditText
android:id="@+id/etCity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:ems="10" android:hint="Enter
City Name"

8
android:inputType="textPersonName"
android:minHeight="48dp" />

<EditText android:id="@+id/etCountry"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:ems="10" android:hint="Enter
Country Code (Optional)"
android:inputType="textPersonName"
android:minHeight="48dp" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/btnGet"
android:layout_marginBottom="10dp"
android:background="#0070c7"
android:textColor="@android:color/white"
android:onClick="getWeatherDetails"
android:text="Get"
app:backgroundTint="@null" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="150dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tvResult" />
</ScrollView> <View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</View>
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/adViewMain"
android:layout_width="wrap_content"
android:layout_height="wrap_content" ads:adSize="SMART_BANNER"
ads:adUnitId="@string/banner_adunit_id">
</com.google.android.gms.ads.AdView>
</LinearLayout>
</LinearLayout>

9
Activity.java
package com.weatherupdate;

import android.graphics.Color;
import android.os.Bundle; import
android.view.View; import
android.widget.EditText; import
android.widget.TextView; import
android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.android.volley.Request; import


com.android.volley.RequestQueue; import
com.android.volley.Response; import
com.android.volley.VolleyError; import
com.android.volley.toolbox.StringRequest; import
com.android.volley.toolbox.Volley; import
com.google.android.gms.ads.AdRequest; import
com.google.android.gms.ads.AdView; import
com.google.android.gms.ads.MobileAds; import
com.google.android.gms.ads.initialization.InitializationStatus;
import com.google.android.gms.ads.initialization.OnInitializationCompleteListener;

import org.json.JSONArray; import


org.json.JSONException; import
org.json.JSONObject;

import java.text.DecimalFormat;

public class MainActivity extends AppCompatActivity {


EditText etCity, etCountry; TextView tvResult; private final String url =
"https://api.openweathermap.org/data/2.5/weather"; private final String
appid = "e53301e27efa0b66d05045d91b2742d3";
DecimalFormat df = new DecimalFormat("#.##");

private AdView mAdView;

@Override protected void onCreate(Bundle


savedInstanceState) {

10
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
MobileAds.initialize(this, new OnInitializationCompleteListener() {
@Override public void onInitializationComplete(InitializationStatus
initializationStatus) {
}
});

mAdView = findViewById(R.id.adViewMain);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);

etCity = findViewById(R.id.etCity);
etCountry = findViewById(R.id.etCountry);
tvResult = findViewById(R.id.tvResult);
}

public void getWeatherDetails(View view) {


String tempUrl = "";
String city = etCity.getText().toString().trim();
String country = etCountry.getText().toString().trim();
if(city.equals("")){ tvResult.setText("City field can
not be empty!");
}else{ if(!country.equals("")){ tempUrl = url + "?q=" +
city + "," + country + "&appid=" + appid;
}else{
tempUrl = url + "?q=" + city + "&appid=" + appid;
}
StringRequest stringRequest = new StringRequest(Request.Method.POST, tempUrl,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
String output = ""; try {
JSONObject jsonResponse = new JSONObject(response);
JSONArray jsonArray = jsonResponse.getJSONArray("weather");
JSONObject jsonObjectWeather = jsonArray.getJSONObject(0);
String description = jsonObjectWeather.getString("description");
JSONObject jsonObjectMain = jsonResponse.getJSONObject("main");
double temp = jsonObjectMain.getDouble("temp") - 273.15;
double feelsLike = jsonObjectMain.getDouble("feels_like") - 273.15;

11
float pressure = jsonObjectMain.getInt("pressure"); int humidity =
jsonObjectMain.getInt("humidity");
JSONObject jsonObjectWind = jsonResponse.getJSONObject("wind");
String wind = jsonObjectWind.getString("speed");
JSONObject jsonObjectClouds = jsonResponse.getJSONObject("clouds");
String clouds = jsonObjectClouds.getString("all");
JSONObject jsonObjectSys = jsonResponse.getJSONObject("sys");
String countryName = jsonObjectSys.getString("country");
String cityName = jsonResponse.getString("name");
tvResult.setTextColor(Color.rgb(68,134,199)); output += "Current
weather of " + cityName + " (" + countryName + ")"
+ "\n Temp: " + df.format(temp) + " °C"
+ "\n Feels Like: " + df.format(feelsLike) + " °C"
+ "\n Humidity: " + humidity + "%"
+ "\n Description: " + description
+ "\n Wind Speed: " + wind + "m/s (meters per second)"
+ "\n Cloudiness: " + clouds + "%"
+ "\n Pressure: " + pressure + " hPa";
tvResult.setText(output); } catch
(JSONException e) { e.printStackTrace();
}
}
}, new Response.ErrorListener(){

@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getApplicationContext(), error.toString().trim(),
Toast.LENGTH_SHORT).show();
}
});
RequestQueue requestQueue = Volley.newRequestQueue(getApplicationContext());
requestQueue.add(stringRequest);
}
}

12
OUTPUT

13
CONCLUSION
In conclusion, the weather application micro project has successfully
demonstrated the integration of various technologies to provide
users with accurate and up-to-date weather information. Through the
utilization of APIs, user-friendly interfaces, and data visualization
techniques, the application offers a seamless experience for users to
access weather forecasts tailored to their location. Additionally, the
project highlights the importance of efficient data handling and
processing to ensure real-time updates and reliability. Moving
forward, further enhancements such as incorporating additional
features, refining the user experience, and optimizing performance
could enhance the application's functionality and appeal to a broader
audience. Overall, the weather application micro project serves as a
testament to the power of technology in delivering valuable and
accessible information to users worldwide.

14
REFERENCES
1. www.google.com
2. www.youtube.com
3. www.w3schools.com
4. www.geeksforgeeks.com
5. www.tutorialspoint.com
6. www.android.com
7. E-Books

15

You might also like