Introduction to Android
Introduction to Android
Android is a mobile operating system developed by Google, based on the Linux kernel,
designed primarily for smartphones and tablets. Over time, it has grown to support wearables
(Android Wear), smart TVs (Android TV), and even automobiles (Android Auto).
This is the foundation of the Android architecture. Android uses a modified version of the Linux
Kernel.
Key Responsibilities:
Analogy: Think of it as the Saiyan body of Goku — solid, raw power, managing all
the internals.
HAL acts as a bridge between hardware and the higher software layers. It provides standard
APIs so that the higher layers don’t need to deal with device-specific hardware code.
Examples:
• Camera HAL
• Bluetooth HAL
• Audio HAL
• Sensor HAL
Analogy: HAL is like Goku's training gi — helps translate his movements properly
to the outer world.
3. Android Runtime (ART) & Core Libraries
Core Libraries:
• Java-based libraries that provide most of the functionalities in the Java programming
language.
• These include collections, file handling, utilities, networking, etc.
Analogy: This is Goku’s training and power boost. ART helps your app run faster
and smoother, just like Ultra Instinct.
These are powerful system libraries written in C/C++ used by Android components via the Java
Native Interface (JNI).
Examples:
Analogy: These are the Z-Fighters — strong backup warriors ready to step in when
Java can’t handle things alone.
This is the most used layer by app developers. It provides APIs that allow developers to interact
with system services and manage UI, resources, content, etc.
Includes:
Analogy: This is like Whis — guiding and controlling the flow of power to different
universes (apps).
Includes:
Analogy: This is the Grand Tournament Arena — where Goku shows off his
powers to the crowd!
Diagram of Android Architecture
Think of it as a magic box that contains all the ingredients to make your app run on your phone.
Just like how a recipe includes all the items to make a dish, an APK contains:
APK Structure:
An APK file is essentially a compressed ZIP archive. Inside, you'll find:
Benefits of APKs:
• Distribute apps outside Google Play.
• Easy for testing and debugging.
• Can be used to install old versions of apps (if you want to rollback).
Summary
Concept Explanation
Android A mobile OS based on the Linux kernel, used in phones, tablets, etc.
Dalvik A runtime used in Android (before Android 5.0) to execute apps via compiled .dex
VM files.
The file format used to distribute Android apps, containing all necessary resources
APK
and code.
Quick Recap in Anime Context
Think of Android as the entire Shonen Jump Universe, with various platforms like your
smartphone being different episodes.
Dalvik was like the old method Goku used to transform into Super Saiyan — works, but not the
most efficient. Then comes ART, the new Super Saiyan Blue, much faster and more efficient.
APK is the Dragon Ball Z DVD you insert into your console — everything needed for the
ultimate fight is contained in one neat package!
1. Activities
An Activity is the entry point to interact with the user. It represents a single screen with a user
interface (UI). Each screen or page you see in an app (like the login screen, home page, etc.) is
typically backed by an activity.
Example:
• When you open the Instagram app, the login page is an activity.
• After logging in, the home page with your feed is another activity.
Activities have a lifecycle — they can be created, paused, resumed, or destroyed depending on
user actions or system needs. These are controlled by callbacks like onCreate(), onStart(),
onResume(), etc. Think of this as the Goku training arc: always evolving and getting better
with each phase.
2. Services
• Music app: When you’re listening to music and switch to another app, the music service
keeps playing in the background.
• Download manager: Downloads files even if you switch to another app.
Types of Services:
• Foreground Service: Runs with a persistent notification (e.g., a music app playing in the
background).
• Background Service: Runs without user interaction, but might be stopped by the system
when resources are low.
• Bound Service: Allows other components (like activities) to bind to it and communicate.
3. Broadcast Receivers
Broadcast Receivers allow the app to listen to system-wide broadcasts or custom messages
sent by other apps. Think of them as the sensors in your app — they receive events and act
accordingly.
• When your phone’s battery is low, a broadcast receiver might be triggered to show a low
battery warning.
• A broadcast receiver might listen for SMS arrival and trigger a notification or update the
UI.
4. Content Providers
A Content Provider is a component used to access shared data across different apps. If your
app needs to read or write data from another app (like contacts, media files), you’ll use a
content provider. • What do Content Providers do?
o They allow data sharing between apps, making sure data is organized in a secure
and consistent way. o They use CRUD operations (Create, Read, Update,
Delete) to interact with data.
Example:
• You can access contacts or the calendar of the device through the respective content
providers.
• Media content providers allow access to images, audio, and video stored on the device.
How it Works:
• The system ensures data consistency and security when accessing content between
different apps, like a gatekeeper ensuring only authorized requests are fulfilled.
UI Components: Views & Notifications
5. Views
Views are the basic building blocks of an Android app’s UI. They represent UI elements such as
buttons, text fields, images, etc., that users can interact with.
6. Notifications
Notifications are messages that pop up outside the regular UI of your app. They allow apps to
notify users about events, even if the app is not open. Think of them as alerts from the universe
telling you something important!
Notification Components:
Quick Summary
Component Description
Activity Single screen in an app, handles user interaction
Service Runs in the background to perform long-running tasks
Broadcast Receiver Listens for system-wide events or messages
Content Provider Allows apps to share data with other apps
View UI components like buttons, text fields, images, etc.
Notification Alerts the user about events outside the app’s UI
Anime Analogy:
• Activity: Your main character going through different story arcs (screens).
• Service: A side character doing important work in the background, like gathering intel
while you focus on fighting.
• Broadcast Receiver: A sensor (like a scouter) receiving messages from the universe
(system events).
• Content Provider: Sharing secret scrolls (data) with other shinobi (apps).
• View: All the interactive elements like buttons, text boxes, etc., on your screen (like the
dynamic battle map in anime).
• Notification: An alert from your sensei, telling you there’s a new mission!
1. Intents & Intent Filters
What is an Intent?
1. Explicit Intents: You explicitly define the component (such as a specific Activity,
Service, or BroadcastReceiver) you want to interact with.
2. Implicit Intents: You don’t specify the component directly. Instead, you specify the
action you want to perform, and the system will find the appropriate app or component to
handle it.
Example:
• Explicit Intent: If you want to launch the MainActivity from another activity in the
same app, you would use an explicit intent.
• Implicit Intent: If you want to send a text message, you would use an implicit intent
with an action like ACTION_SEND and let Android find the appropriate app (e.g.,
WhatsApp, Messages app).
Intent Filters
An Intent Filter defines which Intents a component (Activity, Service, BroadcastReceiver) can
respond to. It’s like a gatekeeper that specifies what kind of messages (intents) can pass
through.
• Purpose: It allows the system to determine which components can handle a particular
action.
• Where used: You define intent filters in the AndroidManifest.xml file, linking an intent
action to a component.
Example:
If you want your app’s activity to handle sharing actions, you’d define an intent filter in your
AndroidManifest.xml:
<activity android:name=".ShareActivity">
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/plain"/>
</intent-filter> </activity>
This tells Android that your activity can handle sending text data.
The API level is a number that corresponds to the version of Android that a particular app is built
to support. Each new version of Android (e.g., Lollipop, Pie) comes with a new API level that
introduces new features and capabilities. When developing an app, developers specify the
minimum and target API levels, ensuring compatibility with different devices.
Example:
• Backward Compatibility: Ensures apps can work on older Android versions, even if
they want to take advantage of new features from newer versions.
• Targeting Features: Allows developers to target specific Android versions and
features, ensuring they aren’t using features that aren’t available in older versions.
Example:
If you’re developing an app that requires fingerprint authentication, you’ll need to set your
minimum API level to at least API 23 (Android 6.0, Marshmallow), as fingerprint APIs were
introduced in that version.
A numeric identifier for Android versions. Each version introduces new features
API Level
and changes.
Version
Codenames given to Android versions (e.g., Lollipop, Pie).
Names
Anime Analogy:
• Intent: Like Goku sending a message to another character to meet him for a fight.
Explicit is when you say exactly who to meet, while Implicit is when you leave it to
others to figure it out based on the type of battle (action)!
• Intent Filter: The gatekeeper of the Dragon Ball Tournament, allowing only certain
fighters (components) to participate in specific types of matches.
• API Level: Think of it like Goku's power level. You can’t expect a Saiyan from Dragon
Ball Z to fight like a Super Saiyan Blue unless you have the right power level (API
version) to handle it.