Topic 2 of 28 · Android Native Developer

Introduction to Android OS, Java Programming Language

Lesson TL;DRTopic 2: Introduction to Android OS, Java Programming Language 📖 11 min read · 🎯 beginner · 🧭 Prerequisites: reasonsformobilefirstapplications, mobileoperatingsystems, androidenvironmentsetuphellow...
11 min read·beginner·android · java · operating-system · android-architecture

Topic 2: Introduction to Android OS, Java Programming Language

📖 11 min read · 🎯 beginner · 🧭 Prerequisites: reasons-for-mobile-first-applications, mobile-operating-systems, android-environment-set-up-hello-world

Why this matters

Here's the thing — before you write a single line of Android code, you need to understand what you're actually building on. Android isn't just a phone screen; it's a full operating system with layers, from a Linux core at the bottom all the way up to the apps people tap every day. And Java is the language you'll use to talk to all of it. If you skip this foundation and jump straight into building, you'll hit walls you can't explain. But once you understand the ground beneath your feet — the Android OS and Java — everything you build from here will make sense from the start.

What You'll Learn

  • What Android is, its key features, and how its layered architecture works
  • What Java is, its key features, and how a basic Java program is structured
  • Core Java concepts: variables, control structures, methods, classes, inheritance, and interfaces
  • How Android and Java combine to power a real Android application

The Analogy

Think of Android as a city's infrastructure — roads, water mains, electrical grids, zoning laws — all managed by a government (the Linux kernel) that citizens never interact with directly. Java is the common language every construction crew in that city uses: architects, plumbers, and electricians all write their plans in Java so anyone can read and execute them. When you write an Android app in Java, you're filing construction permits with the city (the Android SDK), hiring crews who understand the language, and connecting your building to every utility the city provides. The city doesn't care who built the building; it just needs the blueprints in the right language and format.

Chapter 1: Android OS — What It Is and Why It Matters

What is Android?

Android is an open-source operating system designed primarily for touchscreen mobile devices such as smartphones and tablets. Developed by Google, it is based on a modified version of the Linux kernel and other open-source software.

Key Features of Android

  1. Open Source — Android's source code is available for anyone to use, modify, and distribute.
  2. User-Friendly Interface — Android provides an intuitive and customizable user interface.
  3. App Ecosystem — The Google Play Store offers millions of applications for users to download and use.
  4. Multi-Tasking — Android supports multi-tasking, allowing users to run multiple applications simultaneously.
  5. Notifications — Android provides a rich notification system for alerts, updates, and more.
  6. Security — Android incorporates robust security features to protect users' data and privacy.

Chapter 2: Android Architecture — The Layered Stack

Android's architecture is composed of four distinct layers, each providing different functionalities stacked on top of one another.

graph TD
    A["Applications<br/>(Messaging, Browser, Games)"]
    B["Application Framework<br/>(Activity Manager, Resource Manager, Content Providers)"]
    C["Libraries & Android Runtime<br/>(C/C++ Libraries + ART)"]
    D["Linux Kernel<br/>(Security, Memory, Process Management, Hardware)"]

    A --> B
    B --> C
    C --> D
  1. Linux Kernel — At the base, the Linux kernel handles low-level hardware interactions and core system services such as security, memory management, and process management.
  2. Libraries and Android Runtime — Above the kernel, libraries written in C/C++ provide key functionalities. The Android Runtime (ART) executes applications written in Java.
  3. Application Framework — This layer provides higher-level services to applications, such as activity management, resource management, and content providers.
  4. Applications — At the top layer, end-user applications such as messaging, browsing, and games are executed.

Chapter 3: Java — The Language of Android Development

What is Java?

Java is a high-level, object-oriented programming language developed by Sun Microsystems (now owned by Oracle). Known for its portability, reliability, and ease of use, Java is widely used for building enterprise-scale applications, web applications, and, historically, the majority of Android applications.

Note on language choice (2026): Google has officially recommended Kotlin as the primary language for new Android development since 2019, and the Jetpack ecosystem is Kotlin-first. Java still runs perfectly well on Android — every API surface in this lesson is identical from Kotlin — but if you finish this course and apply for an Android role, expect interview questions in Kotlin and Jetpack Compose. Treat this lesson as foundational understanding and plan to pair it with a Kotlin / Compose module before shipping production code.

Key Features of Java

  1. Platform Independence — Java code is compiled into bytecode, which can be run on any device with a Java Virtual Machine (JVM), making it platform-independent.
  2. Object-Oriented — Java uses an object-oriented paradigm, promoting code reuse and modularity.
  3. Robust and Secure — Java provides strong memory management, exception handling, and security features.
  4. Rich API — Java offers a vast standard library (API) for building applications, covering areas such as data structures, networking, and graphical user interfaces.
  5. Multi-Threading — Java supports multi-threading, allowing concurrent execution of multiple threads for efficient performance.

Chapter 4: Basic Java Program Structure

Here is a simple Java program that illustrates the fundamental structure every Java file follows:

// HelloWorld.java
public class HelloWorld {
    // Main method - entry point of the program
    public static void main(String[] args) {
        // Print "Hello, World!" to the console
        System.out.println("Hello, World!");
    }
}

Breaking it down:

  • Class Declarationpublic class HelloWorld declares a class named HelloWorld. Every Java program lives inside at least one class.
  • Main Methodpublic static void main(String[] args) is the entry point of the program. The JVM calls this method to start execution.
  • Print StatementSystem.out.println("Hello, World!"); prints the string "Hello, World!" to the console.

Chapter 5: Key Concepts in Java

These six concepts form the vocabulary you will use every day as an Android developer:

  1. Variables and Data Types — Variables store data values. Java supports various data types such as int, float, char, String, and more.
int age = 25;
float temperature = 36.6f;
char grade = 'A';
String name = "Vizag";
  1. Control Structures — Java provides control structures like if-else, switch, for, while, and do-while to control program flow.
int score = 85;
if (score >= 90) {
    System.out.println("Excellent");
} else if (score >= 70) {
    System.out.println("Good");
} else {
    System.out.println("Needs improvement");
}
  1. Methods — Methods are blocks of code that perform specific tasks. They promote code reuse and modularity.
public static int add(int a, int b) {
    return a + b;
}
  1. Classes and Objects — Classes are blueprints for creating objects. Objects are instances of classes, encapsulating data and behavior.
public class Citizen {
    String name;
    int age;

    public void greet() {
        System.out.println("Hello, I'm " + name);
    }
}

// Creating an object (instance) of Citizen
Citizen c = new Citizen();
c.name = "Anaya";
c.age = 30;
c.greet();
  1. Inheritance — Inheritance allows a class to inherit fields and methods from another class, promoting code reuse.
public class Developer extends Citizen {
    String language;

    public void code() {
        System.out.println(name + " codes in " + language);
    }
}
  1. Interfaces — Interfaces define methods that a class must implement, promoting a contract-based design.
public interface Buildable {
    void build();
}

public class AndroidDev extends Citizen implements Buildable {
    @Override
    public void build() {
        System.out.println(name + " is building an Android app!");
    }
}

Chapter 6: Combining Android and Java — A Real App

Android applications are primarily written in Java. Understanding Java is crucial for developing Android apps, as it allows you to interact with the Android SDK, handle user input, manage the application lifecycle, and more.

Here is a basic Android application that displays "Hello, World!" on the screen, composed of two essential files.

1. MainActivity.java

package com.example.helloworld;

import android.os.Bundle;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // Create a TextView and set its text to "Hello, World!"
        TextView textView = new TextView(this);
        textView.setText("Hello, World!");
        // Set the TextView as the content view of the activity
        setContentView(textView);
    }
}

2. AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.helloworld">
    <application
        android:allowBackup="true"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

What each file does:

  • MainActivity.java — Defines the main activity of the application. It sets up a TextView that displays "Hello, World!" on screen when the app launches.
  • AndroidManifest.xml — Provides essential information about the app to the Android system, including the app's components, permissions, and which activity to launch first. The <intent-filter> block marks MainActivity as the launcher activity — the one that opens when the user taps the app icon.
sequenceDiagram
    participant User
    participant AndroidOS
    participant MainActivity
    participant TextView

    User->>AndroidOS: Taps app icon
    AndroidOS->>MainActivity: Calls onCreate()
    MainActivity->>TextView: new TextView(this)
    MainActivity->>TextView: setText("Hello, World!")
    MainActivity->>AndroidOS: setContentView(textView)
    AndroidOS->>User: Renders "Hello, World!" on screen

🧪 Try It Yourself

Task: Modify the MainActivity.java from this lesson so that instead of displaying "Hello, World!", it displays your own name and your current city — for example, "Hello from Anaya in Vizag!".

Steps:

  1. Open MainActivity.java in Android Studio.
  2. Change the setText argument to your custom string.
  3. Run the app on an emulator or device.

Starter snippet:

TextView textView = new TextView(this);
textView.setText("Hello from YOUR_NAME in YOUR_CITY!");
setContentView(textView);

Success criterion: The emulator or device screen shows your custom greeting text instead of "Hello, World!".

🔍 Checkpoint Quiz

Q1. Which layer of the Android architecture is responsible for executing Java applications at runtime?

A) Linux Kernel
B) Application Framework
C) Libraries and Android Runtime (ART)
D) Applications layer

Q2. Given the following Java snippet, what will be printed to the console?

int x = 10;
if (x > 5) {
    System.out.println("Big");
} else {
    System.out.println("Small");
}

A) Small
B) Big
C) Nothing — the code won't compile
D) Big then Small

Q3. What is the purpose of AndroidManifest.xml in an Android project?

A) It stores the app's UI layout in XML
B) It provides essential information about the app to the Android system, including components and permissions
C) It replaces MainActivity.java when the app is compiled
D) It is only used for publishing the app to the Google Play Store

Q4. You are building an Android app and you want a Bird class to share common behaviors from an Animal class, while also being required to implement a fly() method defined in a Flyable interface. How would you declare Bird in Java?

A1. C — The Android Runtime (ART) sits in the Libraries and Android Runtime layer and is responsible for executing Java-compiled application code.

A2. B — x is 10, which is greater than 5, so the if branch executes and prints "Big".

A3. B — AndroidManifest.xml is the app's declaration file. It tells the Android system about the app's components (activities, services, etc.), required permissions, and which activity to launch first.

A4.

public class Bird extends Animal implements Flyable {
    @Override
    public void fly() {
        System.out.println("Bird is flying!");
    }
}

extends is used for class inheritance (one parent class); implements is used for interfaces (can implement multiple).

🪞 Recap

  • Android is an open-source, Linux-based OS with a four-layer architecture: Linux Kernel → Libraries & ART → Application Framework → Applications.
  • Java is a platform-independent, object-oriented language whose bytecode runs on the JVM (and ART on Android).
  • Every Java program has at least one class and a main method as its entry point; Android apps use onCreate() in an Activity instead.
  • Core Java concepts — variables, control structures, methods, classes, inheritance, and interfaces — are the building blocks of every Android application.
  • MainActivity.java and AndroidManifest.xml work together as the minimum viable pair to launch an Android app.

📚 Further Reading

Like this topic? It’s one of 28 in Android Native Developer.

Block your seat for ₹2,500 and join the next cohort.