Project Weather App
Project Weather App
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
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 express my heartfelt gratitude to all those who supported and guided
me throughout the development of this weather forecasting Android application.
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
)
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.
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.
● 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:
○ Build a mobile app using Android Studio and Java that is capable of
fetching and displaying weather information.
○ Parse the JSON response from the API and extract relevant data such
as temperature, humidity, weather description, and wind speed.
○ Optimize the app for different screen sizes and Android versions to
enhance usability and performance.
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:
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;
@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);
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());
}
});
}
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
}
});
}
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());
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">
<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"/>
<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"/>
package com.avtech.weather.api;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
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;
@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;
package com.avtech.weather.models;
import java.util.List;
// 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; }
<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" />
</manifest>
forecast_item.xml
<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>