Courses / Mobile Application Development (CDE-315) – BS CS 5th Semester
Project Step 1 – Modern Starter: Material 3 Theme, Splash Screen, Resources and Preferences (Labs 1, 3, 10)
Course Project (Java) – Build a Modern Cloud App Step by Step (CampusPulse + 7 ideas) · 90 min read · 6 MCQs to check yourself
Stevdza-San – New Splash Screen API in 60 seconds
Goal
Create the project and give it a modern look: Material 3 theme with dynamic colour, a splash screen, your own colours and logo, and a Prefs helper (SharedPreferences) that later steps use for the session and dark mode.
Labs used: 1 (project, run), 3 (resources), 10 (SharedPreferences).
1.1 Create the project
- File → New → New Project → Empty Views Activity → Next.
- Name:
CampusPulse· Package:pk.edu.uni.campuspulse· Language: Java · Minimum SDK: API 26 (Android 8.0) · Build configuration language: Kotlin DSL (the default – only the Gradle file uses it; all your app code is Java) → Finish. - Run it once on an emulator – you should see "Hello World!" (Lab 1).
We use API 26 because the app uses
java.time(dates and times) without extra setup. Over 98% of phones run Android 8 or newer.
1.2 Add the libraries (all of them now, so later steps only write code)
Open app/build.gradle.kts. Add import java.util.Properties as the first line, and add these parts (keep everything Android Studio created):
import java.util.Properties
// Reads SUPABASE_URL and SUPABASE_KEY from local.properties (filled in Step 7)
val localProps = Properties().apply {
val f = rootProject.file("local.properties")
if (f.exists()) f.inputStream().use { load(it) }
}
android {
// … keep namespace, compileSdk …
defaultConfig {
// … keep applicationId, minSdk = 26, targetSdk, versionCode, versionName …
buildConfigField("String", "SUPABASE_URL", "\"${localProps.getProperty("SUPABASE_URL", "")}\"")
buildConfigField("String", "SUPABASE_KEY", "\"${localProps.getProperty("SUPABASE_KEY", "")}\"")
}
buildFeatures {
viewBinding = true // findViewById-free access to views
buildConfig = true // generates BuildConfig.SUPABASE_URL / SUPABASE_KEY
}
}
dependencies {
// … keep the existing lines (appcompat, material, activity, constraintlayout) …
implementation("androidx.core:core-splashscreen:1.0.1")
implementation("androidx.recyclerview:recyclerview:1.3.2")
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
implementation("com.squareup.retrofit2:retrofit:2.11.0")
implementation("com.squareup.retrofit2:converter-gson:2.11.0")
implementation("com.google.android.gms:play-services-location:21.3.0")
}
Press Sync Now. If Android Studio offers newer versions, accepting them is fine.
1.3 Colours, strings and logo (Lab 3 – resources)
res/values/colors.xml (replace the file):
<resources>
<color name="pulse_primary">#6C4DFF</color> <!-- electric violet -->
<color name="pulse_secondary">#00C2B2</color> <!-- neon teal -->
<color name="pulse_dark">#0B1026</color> <!-- deep space -->
<color name="white">#FFFFFF</color>
<color name="black">#000000</color>
</resources>
res/values/strings.xml (replace – change the values for your own project):
<resources>
<string name="app_name">CampusPulse</string>
<string name="tagline">Your campus, live.</string>
<string name="hello_name">Hi %1$s 👋</string>
<plurals name="events_count">
<item quantity="one">%d upcoming event</item>
<item quantity="other">%d upcoming events</item>
</plurals>
<string name="no_events">No events yet – be the first to post one!</string>
<string name="started">Happening now 🎉</string>
<string name="sending_in">Sending in %d s…</string>
<string name="helpline_phone">0511234567</string>
<string name="uni_website">https://www.example.edu.pk</string>
<string name="support_email">support@example.edu.pk</string>
<string-array name="categories">
<item>Academic</item>
<item>Sports</item>
<item>Tech</item>
<item>Cultural</item>
<item>General</item>
</string-array>
<string-array name="departments">
<item>Computer Science</item>
<item>Software Engineering</item>
<item>Electrical Engineering</item>
<item>Business Administration</item>
<item>Other</item>
</string-array>
</resources>
Logo – right-click res/drawable → New → Drawable Resource File → ic_pulse.xml, then replace its content:
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp" android:height="108dp"
android:viewportWidth="108" android:viewportHeight="108">
<!-- a heartbeat "pulse" line -->
<path android:fillColor="#00000000" android:strokeColor="#00C2B2"
android:strokeWidth="6" android:strokeLineCap="round" android:strokeLineJoin="round"
android:pathData="M28,56 L42,56 L48,40 L56,72 L62,50 L66,56 L80,56" />
</vector>
Gradient card background – res/drawable/bg_gradient.xml:
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:angle="135" android:startColor="#6C4DFF" android:endColor="#00C2B2" />
<corners android:radius="24dp" />
</shape>
Icons – right-click res/drawable → New → Vector Asset → Clip art, and add these Material icons (name them exactly): ic_home (home), ic_add (add), ic_feedback (rate review), ic_person (person), ic_refresh (refresh).
1.4 Material 3 theme + splash screen
Replace res/values/themes.xml:
<resources>
<!-- Main theme: Material 3, follows light/dark mode -->
<style name="Theme.CampusPulse" parent="Theme.Material3.DayNight.NoActionBar">
<item name="colorPrimary">@color/pulse_primary</item>
<item name="colorSecondary">@color/pulse_secondary</item>
</style>
<!-- Splash screen shown while the app starts -->
<style name="Theme.CampusPulse.Splash" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/pulse_dark</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/ic_pulse</item>
<item name="postSplashScreenTheme">@style/Theme.CampusPulse</item>
</style>
<!-- Round avatar shape -->
<style name="CircleImage">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">50%</item>
</style>
</resources>
Delete res/values-night/themes.xml (right-click → Delete) – the DayNight theme already handles dark mode.
1.5 SharedPreferences helper (Lab 10)
Right-click the package → New → Java Class → Prefs:
package pk.edu.uni.campuspulse;
import android.content.Context;
import android.content.SharedPreferences;
import androidx.appcompat.app.AppCompatDelegate;
/** Small things the app remembers on the phone (Lab 10 – SharedPreferences). */
public final class Prefs {
private static SharedPreferences sp;
private Prefs() { }
public static void init(Context context) {
sp = context.getSharedPreferences("campuspulse", Context.MODE_PRIVATE);
}
// ----- session (filled when the user signs in) -----
public static String getAccessToken() { return sp.getString("access_token", null); }
public static void setAccessToken(String v) { sp.edit().putString("access_token", v).apply(); }
public static String getRefreshToken() { return sp.getString("refresh_token", null); }
public static void setRefreshToken(String v) { sp.edit().putString("refresh_token", v).apply(); }
public static String getUserId() { return sp.getString("user_id", null); }
public static void setUserId(String v) { sp.edit().putString("user_id", v).apply(); }
// ----- profile -----
public static String getEmail() { return sp.getString("email", null); }
public static void setEmail(String v) { sp.edit().putString("email", v).apply(); }
public static String getFullName() { return sp.getString("full_name", null); }
public static void setFullName(String v) { sp.edit().putString("full_name", v).apply(); }
// ----- settings -----
public static boolean isDarkMode() { return sp.getBoolean("dark_mode", false); }
public static void setDarkMode(boolean on) {
sp.edit().putBoolean("dark_mode", on).apply();
applyTheme();
}
public static boolean isLoggedIn() { return getAccessToken() != null; }
public static void applyTheme() {
AppCompatDelegate.setDefaultNightMode(isDarkMode()
? AppCompatDelegate.MODE_NIGHT_YES
: AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
}
/** Sign out: forget the session but keep the email so the sign-in form is pre-filled. */
public static void clearSession() {
sp.edit().remove("access_token").remove("refresh_token").remove("user_id").apply();
}
}
1.6 Application class – runs once when the app starts
New Java class CampusPulseApp:
package pk.edu.uni.campuspulse;
import android.app.Application;
import com.google.android.material.color.DynamicColors;
public class CampusPulseApp extends Application {
@Override
public void onCreate() {
super.onCreate();
DynamicColors.applyToActivitiesIfAvailable(this); // "Material You" colours on Android 12+
Prefs.init(this);
Prefs.applyTheme(); // dark / light from the saved setting
Notifier.createChannel(this); // written in Step 2 – add it then
}
}
Until Step 2, put
//in front of theNotifierline so the project builds.
Prefer your own brand colours over wallpaper colours? Delete the
DynamicColorsline.
In AndroidManifest.xml add android:name=".CampusPulseApp" to <application>, and give the launcher activity the splash theme:
<application
android:name=".CampusPulseApp"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.CampusPulse">
<activity
android:name=".MainActivity"
android:exported="true"
android:theme="@style/Theme.CampusPulse.Splash">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
App icon (optional, recommended): right-click res → New → Image Asset → Foreground: Clip art or your logo, Background colour #0B1026 → Finish.
1.7 Show the splash screen
In MainActivity.java, call SplashScreen.installSplashScreen(this) as the first line of onCreate, before super.onCreate:
import androidx.core.splashscreen.SplashScreen;
@Override
protected void onCreate(Bundle savedInstanceState) {
SplashScreen.installSplashScreen(this);
super.onCreate(savedInstanceState);
// … the rest Android Studio created …
}
Run the app: a dark splash with the teal pulse appears, then your app opens in Material 3 colours.
Check before moving on
- Project builds and runs with no errors.
- Splash screen shows the logo.
-
colors.xml,strings.xml,ic_pulse.xml,bg_gradient.xmland the five icons exist. -
Prefs.javaandCampusPulseApp.javaexist and the manifest names the Application class.
Adapt it to your project
Change app_name, tagline, the categories array and the colours. Examples: BloodLink – categories A+, A−, B+, B−, O+, O−, AB+, AB−, a red/rose palette; CleanCity – categories Road, Garbage, Water, Electricity, Other, green/teal palette.
Short and long questions
1. Project viva: How do the Supabase URL and key reach your Java code, and why this way?
Model answer
They are written in local.properties; build.gradle.kts loads that file with java.util.Properties and creates buildConfigField entries, so Java code reads BuildConfig.SUPABASE_URL and BuildConfig.SUPABASE_KEY. local.properties is not committed to Git, so the keys stay out of the public source code.
This lesson ends with a quiz of 6 MCQs. Open the lesson on PrepOasis to take it and save your progress.
Previous: Course Project – Start Here: Choose Your App, Feature Map, Milestones and Rubric · Next: Project Step 2 – Main Screen: Toolbar Menu, Bottom Navigation and Fragments (Labs 5, 8)
All lessons in Mobile Application Development (CDE-315) – BS CS 5th Semester