0% found this document useful (0 votes)
2 views22 pages

Project Weather App

This project report details the development of a weather forecasting Android application as part of a Bachelor of Computer Application curriculum at Ambalika Institute of Higher Education. The application utilizes the OpenWeather API to provide real-time weather data, focusing on user-friendly design and technical skills in Android development. The report covers the project's objectives, roles of team members, and technical implementation, serving as a reference for mobile application development in the weather domain.

Uploaded by

ish9sh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views22 pages

Project Weather App

This project report details the development of a weather forecasting Android application as part of a Bachelor of Computer Application curriculum at Ambalika Institute of Higher Education. The application utilizes the OpenWeather API to provide real-time weather data, focusing on user-friendly design and technical skills in Android development. The report covers the project's objectives, roles of team members, and technical implementation, serving as a reference for mobile application development in the weather domain.

Uploaded by

ish9sh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

A

Project Report
On
“Project title”

UNIVERSITY OF LUCKNOW,U.P
in partial fulfilment of the requirements for the award of the degree
Bachelor of Computer Application
2025
Ambalika institute of Higher Education

Session: 2024-2025

Submitted by:
Amit Prajapati
Ishesh Jaiswal
Aajad Verma

Under the Guidance of Head of Department


Dr Jitendra Kurmi Sir Dr. Shweta Mishra
Preface

This document presents the development process and features of a weather


forecasting Android application created as a part of my BCA curriculum at
Ambalika Institute of Higher Education , Lucknow. The application is
designed to fetch real-time weather data using the OpenWeather API and
provide users with accurate and user-friendly weather information for any
location.

The primary goal of this project was to gain practical experience in Android
development using Java, as well as to understand how external APIs can be
integrated into mobile applications. It also involved learning about UI/UX
design, HTTP networking, API data parsing (JSON), and error handling in
real-world conditions.

This report outlines every aspect of the project—from the initial concept and
design to implementation and testing. I hope this document serves as a useful
reference for anyone interested in mobile application development, particularly
in the field of weather-based apps.

I would like to extend my sincere gratitude to my faculty members, peers, and


everyone who supported me during the course of this project.
Acknowledgement

I would like to express my heartfelt gratitude to all those who supported and guided
me throughout the development of this weather forecasting Android application.

First and foremost, I am deeply thankful to Ambalika Institute of Higher Education


, Lucknow, for providing me with the platform and opportunity to work on this project
as part of my BCA curriculum.

I extend my sincere thanks to my faculty members, especially my project guide, for


their valuable suggestions, continuous encouragement, and constructive feedback
throughout the development process.

I am also grateful to my friends and classmates for their support, cooperation, and
motivation during different phases of this project.

Finally, I would like to thank my family for their unwavering support and inspiration
that helped me complete this work with confidence and dedication.

This project has helped me develop both technical and problem-solving skills, and I
sincerely appreciate the opportunity to apply my learning in a real-world scenario.
INDEX

S No. Title Page No.


Role in Project

Duration of This Project : Around 25 Days

Member 1 : Aajad Verma (Assisted in UI/UX design, choosing the


right layouts, colors, and widgets to ensure a smooth and user-friendly
experience.)

Member 2 : Ishesh Jaiswal ( Responsible for researching and


understanding the OpenWeather API documentation and data formats.​
Handled the API key configuration, managed the internet permissions,
and ensured data security. Assisted in writing the final report and
preparing the presentation for project submission. )

Member 3 : Amit Prajapati ( Responsible for designing and


developing the Android application using Java in Android Studio.​
Integrated the OpenWeather API to fetch real-time weather
data.Implemented core functionalities like location-based search, data
parsing (JSON), and user interface design.

)
Introduction of the Project

In today’s world, weather forecasting plays a crucial role in helping individuals and
organizations plan their daily activities and make informed decisions. With the
increasing reliance on mobile applications, having access to real-time weather
updates has become a necessity for users worldwide.

This project, titled “Weather Forecast Android Application”, is developed to


provide users with accurate and up-to-date weather information directly on their
Android smartphones. The application fetches real-time weather data using the
OpenWeather API and displays it in a clean, user-friendly interface.

The primary objective of this project is to create a reliable weather app that:

●​ Fetches current weather data based on the user’s location or any searched
city.​

●​ Displays important information like temperature, humidity, wind speed, and


weather conditions.​

●​ Provides a smooth and responsive user experience using Android Studio and
Java.​

This project not only showcases technical skills in Android development but also
demonstrates practical implementation of third-party APIs, JSON parsing, and UI/UX
principles. It serves as a learning platform for understanding client-server
architecture, network communication, and mobile design standards.

Through this application, we aim to deliver a useful tool to users while also gaining
hands-on experience in real-world mobile app development.
Objectives of the Project

The primary objective of this project is to design and develop a fully functional
Android-based weather forecasting application using the OpenWeather API. This
application aims to provide accurate, real-time weather updates in a user-friendly
format. The specific objectives of the project are:

1.​ To develop a weather forecasting Android application​

○​ Build a mobile app using Android Studio and Java that is capable of
fetching and displaying weather information.​

2.​ To integrate the OpenWeather API​

○​ Use the OpenWeather API to access real-time weather data for


different cities and geographical locations.​

3.​ For implement location-based weather search​

○​ Enable users to search for weather details by entering city names or by


automatically detecting their current location.​

4.​ To design an intuitive and clean user interface​

○​ Ensure a user-friendly UI with clear weather details, icons, and easy


navigation.​

5.​ For learn and apply JSON parsing techniques​

○​ Parse the JSON response from the API and extract relevant data such
as temperature, humidity, weather description, and wind speed.​

6.​ For ensure compatibility and performance across devices​

○​ Optimize the app for different screen sizes and Android versions to
enhance usability and performance.​

7.​ To gain hands-on experience in mobile app development​

○​ Apply theoretical knowledge in a real-world scenario and strengthen


practical programming and problem-solving skills.
Project Category
This project falls under the category of:

Mobile Application Development (Android)

The application is developed specifically for Android platforms using Java as the
programming language and Android Studio as the integrated development
environment (IDE). The project focuses on:

●​ Real-Time Weather Data Retrieval: By integrating the OpenWeather API,


the app dynamically fetches current weather information from an online
source.​

●​ Client-Server Architecture: It involves sending HTTP requests to a remote


server (OpenWeather) and handling JSON responses, making it a classic
example of a client-server mobile application.​

●​ User Interface & User Experience (UI/UX): Emphasis is placed on creating


a responsive and intuitive interface for a smooth user experience on mobile
devices.​

Thus, the project is categorized as a mobile-based application in the software


development domain, with a focus on real-time data integration and Android
programming
Source Code

MainActivity.java

package com.avtech.weather;

import android.os.Bundle;
import android.view.View;
import android.view.inputmethod.EditorInfo;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import com.avtech.weather.api.ApiClient;
import com.avtech.weather.api.ApiInterface;
import com.avtech.weather.models.ForecastResponse;
import com.avtech.weather.models.WeatherResponse;
import com.squareup.picasso.Picasso;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class MainActivity extends AppCompatActivity {


private EditText etSearch;
private TextView tvCity, tvTemp, tvCondition, tvFeelsLike, tvHumidity, tvWind, tvPressure,
tvVisibility;
private ImageView ivIcon;
private LinearLayout forecastLayout;
private final String API_KEY = "34dff894a2cd053a5f0dc30bbd128520"; // REPLACE
WITH YOUR KEY

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

// Initialize UI components
etSearch = findViewById(R.id.etSearch);
tvCity = findViewById(R.id.tvCity);
tvTemp = findViewById(R.id.tvTemp);
tvCondition = findViewById(R.id.tvCondition);
tvFeelsLike = findViewById(R.id.tvFeelsLike);
tvHumidity = findViewById(R.id.tvHumidity);
tvWind = findViewById(R.id.tvWind);
tvPressure = findViewById(R.id.tvPressure);
tvVisibility = findViewById(R.id.tvVisibility);
ivIcon = findViewById(R.id.ivIcon);
forecastLayout = findViewById(R.id.forecastLayout);

// Set default city


fetchWeather("Lucknow");

// Search on keyboard "Search" button


etSearch.setOnEditorActionListener((v, actionId, event) -> {
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
String city = etSearch.getText().toString().trim();
if (!city.isEmpty()) {
fetchWeather(city);
}
return true;
}
return false;
});
}

private void fetchWeather(String city) {


fetchCurrentWeather(city);
fetchForecast(city);
}

private void fetchCurrentWeather(String city) {


ApiInterface apiInterface = ApiClient.getClient();
Call<WeatherResponse> call = apiInterface.getWeather(city, API_KEY);

call.enqueue(new Callback<WeatherResponse>() {
@Override
public void onResponse(Call<WeatherResponse> call,
Response<WeatherResponse> response) {
if (response.isSuccessful() && response.body() != null) {
updateCurrentWeatherUI(response.body());
} else {
tvCity.setText("City not found");
}
}

@Override
public void onFailure(Call<WeatherResponse> call, Throwable t) {
tvCity.setText("Error: " + t.getMessage());
}
});
}

private void fetchForecast(String city) {


ApiInterface apiInterface = ApiClient.getClient();
Call<ForecastResponse> call = apiInterface.getForecast(city, API_KEY);

call.enqueue(new Callback<ForecastResponse>() {
@Override
public void onResponse(Call<ForecastResponse> call,
Response<ForecastResponse> response) {
if (response.isSuccessful() && response.body() != null) {
updateForecastUI(response.body());
}
}

@Override
public void onFailure(Call<ForecastResponse> call, Throwable t) {
// Handle forecast error
}
});
}

private void updateCurrentWeatherUI(WeatherResponse weather) {


tvCity.setText(weather.getName() + ", " + weather.getSys().getCountry());
tvTemp.setText(String.format("%s°C", Math.round(weather.getMain().getTemp())));
tvCondition.setText(weather.getWeather().get(0).getMain());
tvFeelsLike.setText(String.format("Feels like: %s°C",
Math.round(weather.getMain().getFeelsLike())));
tvHumidity.setText(String.format("Humidity: %s%%", weather.getMain().getHumidity()));
tvWind.setText(String.format("Wind: %s m/s, %s°", weather.getWind().getSpeed(),
weather.getWind().getDeg()));
tvPressure.setText(String.format("Pressure: %s hPa",
weather.getMain().getPressure()));
tvVisibility.setText(String.format("Visibility: %s meters", weather.getVisibility()));

// Load weather icon


String iconUrl = "https://openweathermap.org/img/wn/" +
weather.getWeather().get(0).getIcon() + "@4x.png";
Picasso.get().load(iconUrl).into(ivIcon);
}

private void updateForecastUI(ForecastResponse forecast) {


forecastLayout.removeAllViews();

// We'll use the daily forecast at 12:00 PM for simplicity


for (int i = 0; i < forecast.getList().size(); i++) {
ForecastResponse.ListItem item = forecast.getList().get(i);
// Only use noon forecasts (12:00 PM)
if (item.getDtTxt().contains("12:00:00")) {
addForecastItem(item);
}
}
}

private void addForecastItem(ForecastResponse.ListItem item) {


View forecastItem = getLayoutInflater().inflate(R.layout.forecast_item, forecastLayout,
false);

TextView tvDate = forecastItem.findViewById(R.id.tvDate);


TextView tvTemp = forecastItem.findViewById(R.id.tvForecastTemp);
TextView tvCondition = forecastItem.findViewById(R.id.tvForecastCondition);
ImageView ivIcon = forecastItem.findViewById(R.id.ivForecastIcon);

// Format date to day name


String dateStr = item.getDtTxt();
SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss",
Locale.ENGLISH);
SimpleDateFormat outputFormat = new SimpleDateFormat("EEEE", Locale.ENGLISH);

try {
Date date = inputFormat.parse(dateStr);
tvDate.setText(outputFormat.format(date));
} catch (Exception e) {
tvDate.setText("N/A");
}

tvTemp.setText(String.format("%s°C", Math.round(item.getMain().getTemp())));
tvCondition.setText(item.getWeather().get(0).getMain());

// Load forecast icon


String iconUrl = "https://openweathermap.org/img/wn/" +
item.getWeather().get(0).getIcon() + ".png";
Picasso.get().load(iconUrl).into(ivIcon);

forecastLayout.addView(forecastItem);
}
}
Activity_main.xml

<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<!-- Search Section -->


<EditText
android:id="@+id/etSearch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter City Name"
android:imeOptions="actionSearch"
android:inputType="text"/>

<!-- Current Weather -->


<TextView
android:id="@+id/tvCity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="24sp"
android:layout_marginTop="16dp"/>

<TextView
android:id="@+id/tvTemp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="48sp"/>

<ImageView
android:id="@+id/ivIcon"
android:layout_width="100dp"
android:layout_height="100dp"/>

<TextView
android:id="@+id/tvCondition"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>

<!-- Weather Details -->


<TextView
android:id="@+id/tvFeelsLike"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"/>

<TextView
android:id="@+id/tvHumidity"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

<TextView
android:id="@+id/tvWind"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

<TextView
android:id="@+id/tvPressure"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

<TextView
android:id="@+id/tvVisibility"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

<!-- 5-Day Forecast Title -->


<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="5-Day Forecast"
android:textSize="20sp"
android:layout_marginTop="24dp"/>

<!-- Forecast Items (Simplified) -->


<LinearLayout
android:id="@+id/forecastLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"/>
</LinearLayout>
</ScrollView>
ApiClient.java

package com.avtech.weather.api;

import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public class ApiClient {


private static final String BASE_URL = "https://api.openweathermap.org/data/2.5/";
private static Retrofit retrofit = null;

public static ApiInterface getClient() {


if (retrofit == null) {
retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
}
return retrofit.create(ApiInterface.class);
}
}
ApiInterface.java

package com.avtech.weather.api;

import com.avtech.weather.models.ForecastResponse;
import com.avtech.weather.models.WeatherResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Query;

public interface ApiInterface {


@GET("weather?units=metric")
Call<WeatherResponse> getWeather(
@Query("q") String city,
@Query("appid") String apiKey
);

@GET("forecast?units=metric")
Call<ForecastResponse> getForecast(
@Query("q") String city,
@Query("appid") String apiKey
);
}
ForecastResponse.java

package com.avtech.weather.models;

import java.util.List;

public class ForecastResponse {


private List<ListItem> list;

public List<ListItem> getList() {


return list;
}

// Make inner classes public static


public static class ListItem {
private long dt;
private String dt_txt;
private Main main;
private List<Weather> weather;

public long getDt() { return dt; }


public String getDtTxt() { return dt_txt; }
public Main getMain() { return main; }
public List<Weather> getWeather() { return weather; }
}

public static class Main {


private double temp;

public double getTemp() { return temp; }


}

public static class Weather {


private String main;
private String icon;

public String getMain() { return main; }


public String getIcon() { return icon; }
}
}
WeatherResponse.java

package com.avtech.weather.models;

import java.util.List;

public class WeatherResponse {


private Main main;
private List<Weather> weather;
private Wind wind;
private Sys sys;
private String name;
private int visibility;
private long dt;

// Getters
public Main getMain() { return main; }
public List<Weather> getWeather() { return weather; }
public Wind getWind() { return wind; }
public Sys getSys() { return sys; }
public String getName() { return name; }
public int getVisibility() { return visibility; }
public long getDt() { return dt; }

// Make inner classes public static


public static class Main {
private double temp;
private double feels_like;
private int humidity;
private double pressure;

public double getTemp() { return temp; }


public double getFeelsLike() { return feels_like; }
public int getHumidity() { return humidity; }
public double getPressure() { return pressure; }
}

public static class Weather {


private String main;
private String description;
private String icon;

public String getMain() { return main; }


public String getDescription() { return description; }
public String getIcon() { return icon; }
}
public static class Wind {
private double speed;
private int deg;

public double getSpeed() { return speed; }


public int getDeg() { return deg; }
}

public static class Sys {


private String country;

public String getCountry() { return country; }


}
}
AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />


<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Weather"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />


</intent-filter>
</activity>
</application>

</manifest>
forecast_item.xml

<?xml version="1.0" encoding="utf-8"?>


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="8dp"
android:gravity="center_vertical">

<TextView
android:id="@+id/tvDate"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="16sp"/>

<ImageView
android:id="@+id/ivForecastIcon"
android:layout_width="40dp"
android:layout_height="40dp"/>

<TextView
android:id="@+id/tvForecastTemp"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:textSize="16sp"/>

<TextView
android:id="@+id/tvForecastCondition"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:textSize="16sp"/>
</LinearLayout>

You might also like