Many modern Android applications display an intro video or animated splash screen before opening the main application interface.
Video splash screens are commonly used for:
- Brand introductions
- Gaming applications
- Media applications
- Startup animations
- Promotional app launches
In this tutorial, we will learn how to create a fullscreen video intro splash screen in Android using:
- VideoView
- MediaPlayer listeners
- Raw resource videos
- Automatic screen navigation
What We Will Build
In this Android example:
- Application launches with fullscreen video
- Video automatically starts playing
- Next screen opens after video completion
- Error handling is implemented
- Video is loaded from raw resources
Step 1 — Create activity_main.xml
Create:
res/layout/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:background="@android:color/black">
<VideoView
android:id="@+id/videoView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"/>
</RelativeLayout>
Step 2 — Add Video File
Inside:
res/
create a new folder named:
raw
Add your intro video file inside:
res/raw/
Example:
intro_video.mp4
Step 3 — Create MainActivity.java
Create:
MainActivity.java
package com.example.videosplash;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.widget.Toast;
import android.widget.VideoView;
public class MainActivity
extends AppCompatActivity {
private VideoView videoView;
@Override
protected void onCreate(
Bundle savedInstanceState
) {
super.onCreate(savedInstanceState);
setContentView(
R.layout.activity_main
);
videoView =
findViewById(R.id.videoView);
String videoPath =
"android.resource://"
+ getPackageName()
+ "/"
+ R.raw.intro_video;
Uri uri = Uri.parse(videoPath);
videoView.setVideoURI(uri);
videoView.start();
videoView.setOnCompletionListener(
new MediaPlayer
.OnCompletionListener() {
@Override
public void onCompletion(
MediaPlayer mp
) {
Intent intent =
new Intent(
MainActivity.this,
HomeActivity.class
);
startActivity(intent);
finish();
}
});
videoView.setOnErrorListener(
new MediaPlayer
.OnErrorListener() {
@Override
public boolean onError(
MediaPlayer mp,
int what,
int extra
) {
Toast.makeText(
MainActivity.this,
"Error while playing video",
Toast.LENGTH_LONG
).show();
return true;
}
});
}
@Override
protected void onPause() {
super.onPause();
if (videoView != null) {
videoView.pause();
}
}
@Override
protected void onResume() {
super.onResume();
if (videoView != null) {
videoView.start();
}
}
@Override
protected void onDestroy() {
super.onDestroy();
if (videoView != null) {
videoView.stopPlayback();
}
}
}
Step 4 — Create HomeActivity.java
Create:
HomeActivity.java
package com.example.videosplash;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class HomeActivity
extends AppCompatActivity {
@Override
protected void onCreate(
Bundle savedInstanceState
) {
super.onCreate(savedInstanceState);
setContentView(
R.layout.activity_home
);
}
}
Step 5 — Create activity_home.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="match_parent"
android:gravity="center"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Home Screen"
android:textSize="28sp"/>
</LinearLayout>
Step 6 — Update AndroidManifest.xml
Inside:
AndroidManifest.xml
Add:
<application>
<activity
android:name=".HomeActivity"/>
<activity
android:name=".MainActivity">
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"/>
<category
android:name=
"android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
How This Video Splash Screen Works
The workflow is:
- App launches MainActivity
- VideoView loads intro video
- Video starts automatically
- Completion listener detects video end
- HomeActivity opens automatically
Why Use VideoView?
VideoView provides:
- Simple video playback
- Built-in MediaPlayer integration
- Easy lifecycle handling
- Minimal setup
Common Beginner Mistakes
1. Placing Video Outside raw Folder
Videos must be inside:
res/raw/
2. Using Large Video Files
Huge videos increase:
- APK size
- Loading time
- Memory usage
3. Forgetting Lifecycle Handling
Always pause and release VideoView properly during lifecycle changes.
Modern Android Recommendations
Modern Android applications often prefer:
- Lottie animations
- MotionLayout
- Jetpack Compose animations
- Animated logos
- Lightweight startup screens
VideoView vs ExoPlayer
| VideoView | ExoPlayer |
|---|---|
| Simple implementation | Advanced media features |
| Good for splash videos | Best for streaming apps |
| Basic playback controls | Professional media engine |
Performance Optimization Tips
- Use compressed MP4 videos
- Keep intro short
- Avoid very high resolutions
- Release media resources properly
- Use splash screen API for lightweight startups
FAQ
Can VideoView stream online videos?
Yes, VideoView can stream videos using network URLs.
What is the modern alternative to VideoView?
ExoPlayer is the modern recommended media playback library for advanced applications.
Should apps use long intro videos?
No. Long intro videos may negatively affect user experience and app startup performance.
Conclusion
Video splash screens can create visually engaging application startup experiences when implemented correctly.
Using VideoView with MediaPlayer listeners allows developers to build simple intro video systems with minimal code.
Modern Android applications should balance branding animations with startup performance, smooth navigation, and user experience optimization.
About the Author
Salil Jha is a Full Stack and Mobile Developer specializing in Android, React Native, fintech systems, scalable SaaS platforms, and developer tooling products.
CodeChain Dev — Build Modern Products. Solve Real Problems.
No comments:
Post a Comment