0% found this document useful (0 votes)
2 views17 pages

Introduction to Android

Android is a mobile operating system developed by Google, based on the Linux kernel, supporting various devices like smartphones, tablets, and wearables. Its architecture consists of multiple layers, including the Linux kernel, Android Runtime, and application framework, which facilitate app development and user interaction. Key components of Android include Activities, Services, Broadcast Receivers, Content Providers, Views, and Notifications, each serving specific roles in app functionality.

Uploaded by

shiva941041
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views17 pages

Introduction to Android

Android is a mobile operating system developed by Google, based on the Linux kernel, supporting various devices like smartphones, tablets, and wearables. Its architecture consists of multiple layers, including the Linux kernel, Android Runtime, and application framework, which facilitate app development and user interaction. Key components of Android include Activities, Services, Broadcast Receivers, Content Providers, Views, and Notifications, each serving specific roles in app functionality.

Uploaded by

shiva941041
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

What is 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).

Key Features of Android:


• Open-Source: It's open-source, which means developers can modify and use the code.
• App Ecosystem: Home to the Google Play Store, where millions of apps are available
for download.
• Multitasking & Customization: You can customize the home screen, notifications, and
even the app behavior (thanks to Android’s flexibility).
• Linux Kernel: Android is built on the Linux kernel, giving it a stable and secure
foundation.
• User Interface: Known for its smooth and intuitive UI with touch gestures, widgets, and
app launchers.

Android Architecture Overview:


1. Applications (Apps): The software that users interact with, like WhatsApp, Instagram,
etc.
2. Application Framework: The layer that provides various services to apps, such as
activity management, telephony, and location services.
3. Libraries: Essential for application functionalities, such as SQLite for databases or
WebKit for web browsing.
4. Android Runtime (ART): It executes apps. We'll get into Dalvik (pre-ART) in the next
section.
5. Linux Kernel: The underlying system software that handles memory, hardware, and
processes.

What is Android Architecture?


Android Architecture is a layered stack of components, designed to provide a robust, secure,
and efficient operating system for mobile devices. Each layer has specific responsibilities, from
handling hardware interactions to managing user interfaces.
Android Architecture Components (Layer by Layer)
Here’s a breakdown from bottom to top:

1. Linux Kernel (Base Layer)

This is the foundation of the Android architecture. Android uses a modified version of the Linux
Kernel.

Key Responsibilities:

• Hardware Abstraction (via drivers)


• Process Management
• Memory Management
• Security Enforcement
• Power Management
• Device Drivers (camera, display, Wi-Fi, audio, etc.)

Analogy: Think of it as the Saiyan body of Goku — solid, raw power, managing all
the internals.

2. Hardware Abstraction Layer (HAL)

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

Android Runtime (ART):

• Replaced Dalvik (in Android 5.0+)


• Uses Ahead-of-Time (AOT) compilation: Converts app bytecode to native code at
installation.
• More efficient, better performance, and lower battery consumption.

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.

4. Native C/C++ Libraries

These are powerful system libraries written in C/C++ used by Android components via the Java
Native Interface (JNI).

Examples:

• libc: Standard C library


• SQLite: Database engine
• OpenGL ES: Graphics rendering
• WebKit: Browser engine
• Media Framework: For audio & video playback

Analogy: These are the Z-Fighters — strong backup warriors ready to step in when
Java can’t handle things alone.

5. Android Framework (Java/Kotlin APIs)

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:

• Activity Manager: Manages app lifecycle


• Package Manager: App install/update info
• Window Manager: Manages windows and views
• Notification Manager
• Telephony Manager
• Location Manager
• Resource Manager

Analogy: This is like Whis — guiding and controlling the flow of power to different
universes (apps).

6. Applications (Top Layer)

This is the user-facing layer — where the magic happens

Includes:

• System apps: Phone, Messages, Camera, etc.


• Third-party apps: WhatsApp, Instagram, etc.
• Custom apps: Your own creations

Analogy: This is the Grand Tournament Arena — where Goku shows off his
powers to the crowd!
Diagram of Android Architecture

Quick Recap Table


Layer Description
Applications User-level apps (your app, system apps)
Framework APIs for UI, activity, content, resources, etc.
Runtime & Native Libs ART for code execution + native C/C++ libraries
HAL Interface between hardware and framework
Linux Kernel Core OS for memory, security, hardware drivers
Dalvik Virtual Machine (DVM)
Before Android 5.0 (Lollipop), Dalvik was the runtime environment used to run Android
applications. It is a virtual machine (VM) specifically designed for Android, optimized for low
memory and CPU usage in mobile devices.

What Does Dalvik Do?


Dalvik executes compiled bytecode in the form of .dex (Dalvik Executable) files. These files
are created from Java source code, which is then compiled into Java .class files and further into
.dex files using the dx tool.
Dalvik vs. Java Virtual Machine (JVM)
• JVM (Java Virtual Machine) is used to run Java applications on desktop or server
environments.
• Dalvik was created for mobile devices with constraints like limited CPU, RAM, and
battery. It is more optimized for these conditions than the traditional JVM.
• The Dalvik VM is also register-based, meaning it uses registers for operations, unlike
JVM which is stack-based. This makes Dalvik more efficient for mobile devices.

Transition to ART (Android Runtime)


• In Android 5.0 Lollipop, Dalvik was replaced by ART (Android Runtime).
• ART offers better performance because it uses Ahead-Of-Time (AOT) compilation,
where the app is compiled during installation instead of running through a virtual
machine during runtime (as Dalvik did with Just-in-Time (JIT) compilation).

.apk File Extension


What is an APK?
The .apk (Android Package) file is the installer package used by the Android operating system
to install apps. It’s like a compressed container that holds everything needed to run an app on an
Android device.

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:

• App code (in the form of .dex files)


• Resources (images, layouts, etc.)
• Manifest file (AndroidManifest.xml) which holds metadata like app permissions,
activities, etc.

APK Structure:
An APK file is essentially a compressed ZIP archive. Inside, you'll find:

• META-INF: Contains metadata about the APK.


• lib/: Libraries required for the app to run.
• res/: Resources like images and layouts.
• assets/: Raw assets that can be bundled with the app.
• AndroidManifest.xml: Contains essential details about the app (permissions,
components like Activities/Services, etc.).
• classes.dex: The Dalvik Executable files, containing the compiled code.
• resources.arsc: A file containing precompiled resources.

How to Install APKs?


• Normally, apps are installed from the Google Play Store, but third-party APKs can also
be installed (outside the Play Store) by enabling installing from unknown sources.
• Installing .apk files manually is common for sideloading apps, testing apps during
development, or for getting apps not available in your region.

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!

Fundamentals: Basic Building Blocks in Android

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.

• What does an Activity do?


o It controls the UI components (buttons, text fields, images) of the screen. o
Handles user interaction like clicks, text inputs, etc.
o Activities are stacked in the backstack (like piled up episodes in an anime
queue), where each activity pushes the next one on top.

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.

Life Cycle of an 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

A Service is a component that runs in the background to perform long-running operations


without interacting directly with the user. Services can run indefinitely (even when the user isn’t
interacting with the app).

• What does a Service do?


o Handles background tasks like playing music, downloading files, syncing data,
etc.
o Unlike activities, services do not have a UI.
o Services are crucial for things like background notifications, media playback,
etc.
Example:

• 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.

• What do Broadcast Receivers do?


o They don’t display UI; instead, they receive events from other parts of the system
or apps, like battery status changes, network availability, etc. o They listen
for messages and react to them, like showing a notification or performing some
action.
Example:

• 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.

Common System Broadcasts:

• BOOT_COMPLETED: Fired when the system finishes booting.


• CONNECTIVITY_CHANGE: Fired when network connectivity changes (WiFi, mobile
data).
• BATTERY_LOW: Fired when battery is low.

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.

• What do Views do?


o Every widget you see in an app — buttons, images, sliders — is a View. o
Views can be customized and arranged using Layouts to create the overall UI.

Common Types of Views:

• Text View: Displays text.


• Button: A clickable button.
• Edit Text: Allows users to input text.
• Image View: Displays an image.
• Checkbox: Displays a checkbox.

View Groups (Layouts):

• LinearLayout: Arranges views in a single row or column.


• RelativeLayout: Views are positioned relative to each other.
• ConstraintLayout: More flexible and efficient for complex UI structures.

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!

• What do Notifications do?


o They are typically used to alert the user about an important event or to remind
them about something, like a missed call, a new message, or a reminder. o
Push Notifications: Sent from a remote server to your device to alert you
about something important.
Example:

• A new message in WhatsApp — a notification appears on your lock screen.


• Reminders about upcoming meetings or events.

Notification Components:

• Title and text: Brief information about the notification.


• Icon: A small image/icon representing the app or the event.
• Action buttons: Allow users to take immediate action (e.g., reply to a message from the
notification).

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?

An Intent in Android is a messenger that allows you to request an action or communicate


between different components of an app or even between apps. It’s like sending a letter to tell
another part of the system or app what to do.

There are two types of intents:

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).

Syntax for Creating an Intent:


Intent intent = new Intent(this, TargetActivity.class); // Explicit
startActivity(intent);

For implicit intents, you can specify an action:

Intent intent = new Intent(Intent.ACTION_SEND);


intent.putExtra(Intent.EXTRA_TEXT, "Hello there!");
intent.setType("text/plain"); startActivity(intent);

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.

2. Android API Levels (Versions & Version Names)


Android releases are identified by API levels, which are numeric values associated with specific
versions of Android. As Android evolves, the API level increases, which enables developers to
target specific features and behaviors of each version.
What is an API Level?

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:

• API Level 29 corresponds to Android 10.


• API Level 30 corresponds to Android 11.

API Level and Version Names:


Each Android version is associated with an API level and a version name (which is the
codename). Over time, Android versions are named after desserts (earlier) or are just numbered
(more recent versions).
Android Version Name API Level Version Name Release Date
Cupcake 3 1.5 April 27, 2009
Donut 4 1.6 September 15, 2009
Eclair 5-7 2.0-2.1 October 26, 2009
FroYo 8 2.2 May 20, 2010
Gingerbread 9-10 2.3 December 6, 2010
Honeycomb 11-13 3.0-3.2 February 22, 2011
Ice Cream Sandwich 14-15 4.0-4.0.4 October 18, 2011
Jelly Bean 16-18 4.1-4.3.1 July 9, 2012
KitKat 19 4.4 October 31, 2013
Lollipop 21-22 5.0-5.1 November 12, 2014
Marshmallow 23 6.0 October 5, 2015
Nougat 24-25 7.0-7.1.2 August 22, 2016
Oreo 26-27 8.0-8.1 August 21, 2017
Pie 28 9.0 August 6, 2018
Android 10 29 10 September 3, 2019
Android 11 30 11 September 8, 2020
Android 12 31 12 October 4, 2021
Android 13 33 13 August 15, 2022

Why API Levels Matter?

• 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.

Key Concepts Recap


Component Description
A message that can be sent between Android components (Activities, Services,
Intent
Broadcast Receivers). Can be explicit or implicit.
A filter that specifies which intents a component can respond to, defined in the
Intent Filter
AndroidManifest.xml.

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.

You might also like