TY Practical No. 13 Develop a Splash Screen in Android
Practical No. 13
Develop a Splash Screen in Android
Aim
To develop an Android application that displays a Splash Screen showing
“Student Name: FirstName LastName” and automatically navigates to the main activity after a fixed delay.
I. Practical Significance
This practical helps students understand:
Android Activity Lifecycle
Timed transitions between activities
Basic branding and first-impression UI design
Splash screens are commonly used in industry to enhance user experience during app startup.
II. Industry / Employer Expected Outcome(s)
After completing this practical, students will be able to:
Implement a professional splash screen
Use
Handler.postDelayed()for timed executionNavigate between activities using
IntentConfigure launcher activities in
AndroidManifest.xml
III. Course Level Learning Outcome(s)
CO3 – Develop Android applications using UI components and layouts.
IV. Laboratory Learning Outcome(s)
LLO 13.1 – Write a program to develop a relevant GUI for a given application.
V. Relevant Affective Domain Related Outcomes
Promotes attention to user experience
Encourages focus on first impressions in application design
VI. Relevant Theoretical Background
Activity Lifecycle
onCreate()initializes the activity;finish()removes it from the back stack.Handler and Delay
Handler.postDelayed()executes code after a specified time delay.Intent Navigation
Used to launchMainActivityfromSplashActivity.UI Components
ImageView,TextView,RelativeLayoutManifest Configuration
Splash activity is defined as the launcher activity.
VII. Project File Structure (Tree Diagram)
SplashScreenApp/
├── app/
│ └── src/
│ └── main/
│ ├── java/com/example/splashscreenapp/
│ │ ├── SplashActivity.java
│ │ └── MainActivity.java
│ ├── res/
│ │ ├── layout/
│ │ │ ├── activity_splash.xml
│ │ │ └── activity_main.xml
│ │ ├── drawable/
│ │ │ └── splash_logo.png
│ │ └── values/
│ │ └── styles.xml
│ └── AndroidManifest.xml
VIII. Program Code (Final & Corrected)
1. SplashActivity.java
package com.example.splashscreenapp;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import androidx.appcompat.app.AppCompatActivity;
public class SplashActivity extends AppCompatActivity {
private static final int SPLASH_TIME = 3000; // 3 seconds
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(SplashActivity.this, MainActivity.class);
startActivity(intent);
finish();
}
}, SPLASH_TIME);
}
}
2. MainActivity.java
package com.example.splashscreenapp;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
3. activity_splash.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF">
<ImageView
android:id="@+id/imgLogo"
android:layout_width="120dp"
android:layout_height="120dp"
android:src="@drawable/splash_logo"
android:layout_centerHorizontal="true"
android:layout_marginTop="120dp" />
<TextView
android:id="@+id/txtStudent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Student Name: FirstName LastName"
android:textSize="18sp"
android:textStyle="bold"
android:layout_below="@id/imgLogo"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp" />
</RelativeLayout>
4. activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Welcome to Main Activity"
android:textSize="22sp"
android:textStyle="bold" />
</RelativeLayout>
5. AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.splashscreenapp">
<application
android:allowBackup="true"
android:label="SplashScreenApp"
android:theme="@style/Theme.AppCompat.Light.NoActionBar">
<activity android:name=".MainActivity" />
<activity android:name=".SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
IX. Expected Output (Splash Screen)
Output Description:
App launches with a splash screen
Logo and text
“Student Name: FirstName LastName” are displayedAfter 3 seconds, the app navigates automatically to the Main Activity
X. Result
Thus, a Splash Screen Android application was successfully developed using activity lifecycle methods, handler-based delay, intent navigation, and proper manifest configuration.
