0% found this document useful (0 votes)
3 views80 pages

Android Unit I

The document provides an overview of the Android computing platform, including its history, software stack, architecture, and development environment setup. It details the evolution of Android versions from 1.0 to 11, highlighting key features and improvements in each release. Additionally, it covers the Android SDK, Java packages, and the use of Android Studio for application development.

Uploaded by

stuvwxyz.1864
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)
3 views80 pages

Android Unit I

The document provides an overview of the Android computing platform, including its history, software stack, architecture, and development environment setup. It details the evolution of Android versions from 1.0 to 11, highlighting key features and improvements in each release. Additionally, it covers the Android SDK, Java packages, and the use of Android Studio for application development.

Uploaded by

stuvwxyz.1864
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

Android Programming

Unit I

Introducing the android computing platform, History of android, Android


software stack, Developing end user application using Android SDK, Android
java packages, Setting up the development environment, Installing android
development tools (ADT), Fundamental components, Android virtual devices,
Running on real device, Structure of android application, Application life cycle.
WHAT IS ANDROID?
▪ Android is a software package and an open source linux- based operating system for mobile
devices such as smartphones and tablet computers
▪ Android offers unified approach to application development for mobile devices
▪ Developers need only develop for android , and their applications should be able to run on
different devices powered by android.
▪ Irina Blok: designed the official android logo
▪ The platform that’s changing what mobile can do.

HISTORY
▪ Android Inc. was founded in Palo Alto of California by Andy Rubin, Rich Miner ,Nick sears
and Chris White in 2003
▪ Android Inc. was acquired by Google in 2005 to start the development of Android platform.
▪ November 5 is celebrated as android’s birthday
▪ Android SDK was first issued as an early look release in November 5, 2007 with the founding
of Open Handset Alliance(OHA) , a consortium for 84 hardware ,software ,and
telecommunication companies aimed to advancing open standards for mobile devices.
▪ In September 2008 HTC released T-mobile G1(HTC Dream), the first smartphone based on
android platform.
▪ In September 2008 HTC released T-mobile G1(HTC Dream), the first smartphone based on
android platform.
VERSION HISTORY

▪ The version history of the Android mobile operating system began with the public release of
the Android beta on November 5, 2007
▪ The first commercial version, Android 1.0, was released on September 23, 2008.
▪ Android is continually developed by Google and the Open Handset Alliance, and it has seen
several updates to its base operating system since the initial release.
▪ Android 1.0 and 1.1 were not released under specific code names, although Android 1.1 was
unofficially known as Petit Four.
▪ Android code names were confectionery-themed and have been in alphabetical order since
2009's Android 1.5 Cupcake.
▪ Google ended the confectionery theming scheme in 2019 beginning with Android 10
▪ The most recent version of Android is Android 11, which was released on September 8
,2020.
CUPCAKE 1.5
▪ Released in April 2009
▪ First version of Android to have an on-screen keyboard
▪ Ability to upload videos to YouTube, support for third-party keyboards,
and feature like automatically rotating phone’s screen to the right
positions.
▪ The first Samsung Galaxy phone had the Android 1.5 cupcake.

DONUT 1.6
▪ Main feature included in Donut was that it supported carriers that used
CDMA based networks
▪ Ability for the OS to operate on a variety of different screen sizes and
resolutions
▪ It also included features like quick switching between the Cameras,
Camcorder, and Gallery
▪ introduced the Quick Search Box.
ANDROID 2.0-2.1 ÉCLAIR
▪ First Android version with text-to-speech support.
▪ Introduced multiple account support, live wallpapers, navigation with
Google Maps
▪ First smartphone with the Android 2.0 version was the Motorola
Droid,

ANDROID 2.2 FROYO

▪ Froyo, short form for Frozen Yogurt was launched in May 2010.
▪ Wi-Fi mobile hotspot functions was introduced.
▪ It also included many other features such as flash support, push
notifications via Android Cloud to Device Messaging (C2DM) service,
and more.
ANDROID 2.3 GINGERBREAD

▪ Launched in September 2010.


▪ Updated UI design that provided increased efficiency and ease-of-use.
▪ It had support for extra-large screen sizes and resolution.
▪ More features such as native support for SIP VoIP internet telephones, improved text inputs
using the virtual keyboard, better text suggestions and voice input capability were added
▪ One of the key features was its support for using NFC (near field communication) functions
for smartphones.
ANDROID 3.0 HONEYCOMB

▪ Honeycomb was launched to be installed only for tablets and mobile devices with larger
screens

▪ Google aimed for features that could not be handled by smartphones with smaller screens.

▪ But Honeycomb ended up as a version that not really required.

▪ Most of the features of Honeycomb were integrated with the next major version of Android.
ANDROID 4.0 ICE CREAM SANDWICH

▪ Features of the previous version, Honeycomb, were integrated with the Ice Cream Sandwich
version.

▪ This version was the first to introduce the feature to unlock the phone using its camera.

▪ Other notable changes with Ice Cream Sandwich included support for all the on-screen
buttons, the ability to monitor the mobile and Wi-Fi data usage, and swipe gestures to
dismiss notifications and browser tabs.
ANDROID 4.1-4.3 JELLY BEAN
▪ The notification part was improved a lot in this version.
▪ Full support for Google Chrome (Android version) was included in
Android 4.2.
▪ Android’s touch responsiveness was also improved.
▪ Jelly Bean was collectively the first Android version to support emoji and
screensavers that are natively done.
ANDROID 4.4 KITKAT
▪ KitKat did not have many features.
▪ But one main feature was that KitKat could run on smartphones with
even a 512 MB RAM.
▪ It was because KitKat used the Android Runtime (ART), though
experimental, instead of the DVM (Dalvik Virtual Machine) originally
used by Android.
ANDROID 5.0 LOLLIPOP

▪ Google’s new Material Design language was first introduced in Lollipop

▪ It included changes in UIs like a revamped navigation bar and better-style notifications for
the lock-screen etc.

▪ It brought the Flat Design concept into play.

▪ Google created more enhancements to Android devices’ battery life with a Doze mode
where background apps are killed once the show is turned off.
6.0 MARSHMALLOW
▪ First, the Android 6.0 version was to be called Macadamia Nut Cookie, but it was released
as Marshmallow in May 2015.

▪ Marshmallow brought the addition of the memory manager,

▪ This was the first version that had native support for unlocking of the smartphone with
biometric; fingerprint authentication.

▪ USB Type C support was included and Android pay was also introduced in Marshmallow.
ANDROID 7.0 NOUGAT

▪ Android 7.0 Nougat was released in August 2016.


▪ It came out with multitasking features, especially for smartphones with bigger screens.
▪ It included split-screen and fast switching between apps.
▪ Many changes behind the scenes were also made by Google such as switching to a new JIT
compiler that could speed up apps.
▪ Google’s own smartphone, the Pixel, and Pixel XL, and LG V20 came out with Android 7.0
Nougat.
ANDROID 8.0 OREO

▪ It included many visual changes such as native support for picture-in-picture mode, new
autofill APIs that could help in better managing the passwords and fill data, notification
channels
ANDROID 9.0 PIE
▪ Released in August 2018.
▪ It came with a lot of new features and improvements.
▪ The new home-button was added in this version. When swiped up, it
brings the apps used recently, a search bar and suggestions of five
apps at the bottom.
▪ There was a new option added of swiping left to see the currently
running apps.
▪ Improvements in battery life were also made in this version.
▪ Shush mode, a new feature was also added. It automatically puts the
smartphone in Do not disturb mode. All you need to do is place your
phone on any surface face down and DND will be automatically
enabled.
▪ Added “Digital Wellbeing,” a feature that essentially tells you how
often you use your phone, the apps that you use the most
ANDROID 10
▪ Along with the rollout of the latest version of Android, Google also announced a rebranding
of the operating system, doing away with the naming scheme and instead sticking with
version numbers only.
▪ Google also announced a new logo for Android, and a new color scheme.
▪ Android 10 marked the end of the Android navigation buttons.
▪ While Android 9 kept the back button, Android 10 now uses gestures instead
▪ Android 10 also brought a systemwide dark mode
▪ Another features include Sound Amplifier, faster security updates , Digital well being, set
screen time limits, view app activity, manage apps and content restrictions
ANDROID 11

▪ Google released Android 11 on September 8, 2020


▪ Features
o Conversations
o Built-in screen recording
o Predictive tools
o Voice access
o Device Controls
o More security and privacy fixes sent to your phone from Google
o Play.
ANDROID SOFTWARE STACK

▪ A solution stack or software stack is a set of software systems or components needed to


create complete platform such that no additional software is needed to support
applications
▪ Android OS is a stack of software components which is divided into 5 sections and 4 main
layers
▪ Linux kernel
▪ Native libraries (middleware),
▪ Android Runtime
▪ Application Framework
▪ Applications
ANDROID ARCHITECTURE
1. Linux kernel

▪ The term ‘kernel’ means ‘core’ as the name indicates ,It is the heart of android architecture
that exists at the root of android architecture.
▪ Linux kernel is the base of the software layers upon which all other layers of the android
are built.
▪ Users are not allowed to directly interact with this layer.
▪ All the essential hardware drivers are located in Linux Kernel which communicates with the
hardware.
▪ Linux Kernel can also act as an abstraction layer between hardware and software layers
1. Linux kernel

▪ The following are the important functions of kernel in the android system:
o Hardware abstraction
o Memory management programs
o Security settings
o Power management software
o Support for shared libraries
o Network stack
o Device driver management
2. Native Libraries

▪ Next to Linux Kernel layer is the Android’s Native Libraries.


▪ They provide capabilities for android’s core features. Libraries help the device to handle
different types of data.
▪ The following are some of the important native libraries:
▪ Surface Manager: manages access to the display subsystem and 2D and 3D graphic
layers from multiple applications .
▪ Media Framework: for playing and recording audio and video formats.
▪ SQLite : is an android database engine which stores data.
▪ WebKit : is a browser engine that displays HTML content.
▪ OpenGL : renders 2D or 3D graphic contents on the screen.
▪ FreeType :for font support
▪ C runtime library (libc)
3. Android Runtime

▪ This is the 3rd section of the architecture and available on the second layer from the
bottom
▪ In android runtime, there are core libraries and DVM (Dalvik Virtual Machine) which is
responsible to run android application.
▪ DVM is like JVM but it is optimized for mobile devices. It consumes less memory and
provides fast performance.
▪ DVM takes the generated java class files and combines them into one or more .dex files
▪ Goal of DVM is to find every possible ways to optimize the JVM for space, performance and
battery life
▪ The javac tool compiles the java source file into the class file.
▪ The dx tool takes all the class files of your
▪ application and generates a single .dex file.
▪ It is a platform-specific tool.
▪ The Android Assets Packaging Tool (aapt) handles the packaging process.
4. Android Framework

▪ On the top of Native libraries and android runtime, there is android framework.
▪ Android framework layer which is written in Java includes Android API's such as UI (User
Interface), telephony, resources, locations, Content Providers (data) and package managers.
▪ It provides a lot of classes and interfaces for android application development.
▪ The following are some of the basic tools with which applications are built:
▪ Activity Manager : Activity life cycles of applications are managed.
▪ Content Providers : data sharing among applications are managed.
▪ Telephony Manager : manages the location via GPS or base station receiver.
▪ Resource Manager : various types of resources used in applications are managed.
5. Applications

▪ On the top of android framework, there are applications.


▪ All applications such as home, contact, settings, games, browsers are using android
framework that uses android runtime and libraries.
▪ Android runtime and native libraries are using linux kernel.
ANDROID JAVA PACKAGES

▪ [Link]: implements application model for android


▪ [Link]: Provides device administration features at the system level
▪ [Link]: provides classes to manage accounts such as google, facebook
▪ [Link]: to apply animation for different objects, animation classes and
methods are included
▪ [Link]: Contains the backup and restore functionality available to
applications. If a user wipes the data on their device or upgrades to a new Android-
powered device, all applications that have enabled backup can restore the user's previous
data when the application is reinstalled.
▪ [Link]:Manages access to a central repository of data
▪ [Link]:Contains classes to explore data returned through a content provider.
ANDROID JAVA PACKAGES

▪ [Link]: Contains the SQLite database management classes that an


application would use to manage its own private database.
▪ [Link]: Provides low level graphics tools such as canvases, color filters, points,
and rectangles that let you handle drawing to the screen directly.
▪ [Link]: supports video streaming and play audio and video files
▪ [Link]: provides operating system services through java such as IPC, file server
management etc.
▪ [Link]: provides text processing classes
▪ [Link]: contains classes menu, view, viewgroups and a series of listeners
▪ [Link]: classes representimg web browser
▪ [Link]: contains all of the UI controls(list, grid, image)
SETTING UP THE DEVELOPMENT ENVIRONMENT
▪ Downloading JDK(The Android SDK requires JDK 5 or higher)
• After installing set PATH variables
▪ Download the Eclipse IDE
▪ Downloading the Android SDK
• The SDK contains 2 parts. base tools & package
• The tools part includes an emulator and a setup utility to install the packages.
• The packages are the files specific to a particular version of Android (called a platform)
or a particular add-on to a platform(ex: google maps, vendor specific apps)
▪ Updating path environmental variable
▪ Installing Android Development Tools (ADT)
• Eclipse plug-in that helps to build Android applications.
▪ From Eclipse, you can launch the SDK Manager. To do so, choose Window ➤ Android SDK
Manager.
ANDROID STUDIO

▪ Android Studio is the official Integrated Development Environment (IDE) for Android app
development

▪ It is based on the IntelliJ IDEA, a Java integrated development environment for software,
and incorporates its code editing and developer tools.

▪ The first stable build was released in December 2014, starting from version 1.0.

▪ It replaced Eclipse Android Development Tools (ADT) as the primary IDE for Android
application development.

▪ Since May 7, 2019, Kotlin is Google’s preferred language for Android app development
INSTALLING ANDROID STUDIO
▪ Launch android [Link] file
• Before launching machine should require installed Java JDK
• Studio setup will detect the jdk path automatically. if not specify the jdk path
▪ Check the components required to create applications(like android studio, android SDK,
android virtual device and performance)
▪ Specify the location of local machine path for android studio and android sdk
• Minimum 500 mb of free space for studio and 1.5 GB for SDK
▪ Specify ram space for android emulator
• By default it takes 512 MB
▪ At final stage it extracts SDK packages into local machine
▪ After completion get the finish button
RUNNING ANDROID STUDIO
▪ The first time Android Studio runs, it presents a Complete Installation dialog box that
offers the option of importing settings from a previous installation.
ANDROID STUDIO SETUP WIZARD
SELECT AN INSTALLATION TYPE

VERIFY SETTINGS
DOWNLOADING SDK COMPONENTS
WELCOME TO ANDROID STUDIO
▪ Android Studio 4.1 (August 2020) is the current major version
DEVELOPING END USER APPLICATION USING ANDROID SDK

1. Android Emulator
▪ The Android SDK includes a virtual mobile device emulator that runs on the computer.
▪ The emulator lets you prototype, develop and test Android applications without using a
physical device.
▪ Emulator can used to run, debug, and test applications. You will not even need the real
device for 90 percent of your application development
▪ The full-featured Android emulator mimics most of the device features, some limitations
regarding USB connections, camera and video capture, head- phones, battery simulation,
and Bluetooth.
▪ The Android emulator accomplishes its work through an open source “processor emulator”
technology called QEMU developed by Fabrice Bellard.
DEVELOPING END USER APPLICATION USING ANDROID SDK

2. The Android UI
▪ Android uses a UI framework that resembles other desktop-based, full-featured UI frame-
works, but it’s more modern and more asynchronous in nature.
▪ Android is almost a fourth-generation UI framework
• traditional C-based Microsoft Windows API -the first generation
• C++-based MFC (Microsoft Foundation Classes) – second generation.
• The Java-based Swing UI framework -third generation,
• The Android UI, JavaFX, Microsoft Silverlight, and Mozilla XML User Interface Language
(XUL) - fourth-generation UI framework
▪ UI is declarative and independently themed.
DEVELOPING END USER APPLICATION USING ANDROID SDK

2. The Android UI (Continues..)


▪ Programming in the Android UI involves declaring the interface in XML files.
▪ load these XML view definitions as windows in your UI application.
▪ Even menus in application are loaded from XML files
▪ Screens or windows in Android are referred to as activities,
▪ comprise multiple views that a user needs in order to accomplish a logical unit of action.
▪ Views are Android’s basic UI building blocks, and it can be combined to form composite
views called view groups.
DEVELOPING END USER APPLICATION USING ANDROID SDK

3. The Android Foundational Components


▪ The core building blocks or fundamental components of android are activities, views,
intents, services, content providers, fragments and [Link].
▪ Activity: An activity is a class that represents a single screen. It is like a Frame in AWT.
▪ View: A view is the UI element such as button, label, text field etc. Anything that you see is
a view.
▪ Intent: Intent is used to invoke components. It is mainly used to:
o Start the service
o Launch an activity
o Display a web page
o Display a list of contacts
o Broadcast a message
o Dial a phone call etc.
DEVELOPING END USER APPLICATION USING ANDROID SDK

3. The Android Foundational Components (Continues..)


▪ Service
• Service is a background process that can run for a long time.
• There are two types of services local and remote. Local service is accessed from within
the application whereas remote service is accessed remotely from other applications
running on the same device.
▪ Content Provider
• Content Providers are used to share data between the applications.
▪ Fragment
• Fragments are like parts of activity.
• An activity can display one or more fragments on the screen at the same time.
▪ [Link]
• It contains information about activities, content providers, permissions etc.
FUNDAMENTAL COMPONENTS
▪ An android component is simply a piece of code that has a well defined life cycle
▪ Fundamental components or application components are the essential building blocks of
an android application
• views
• Activities
• fragments
• intents
• content providers
• Services
• [Link] file
• Broadcast receiver
FUNDAMENTAL COMPONENTS
Views
▪ Views are user interface (UI) elements that form the basic building blocks of a user
interface.
▪ A view can be a button, a label, a text field, or many other UI elements.
▪ Views are also used as containers for views, which means there’s usually a hierarchy of
views in the UI.
▪ In the end, everything you see is a view.

Activity
▪ An activity is a UI concept that usually represents a single screen in your application.
▪ It generally contains one or more views.
▪ Activity performs actions on the screen
▪ viewing data, creating data, or editing data
FUNDAMENTAL COMPONENTS
Fragment
▪ When a screen is large, it becomes difficult to manage all of its functionality in a single
activity.
▪ Fragments are like sub-activities, and an activity can display one or more fragments on the
screen at the same time.
▪ When a screen is small, an activity contain just one fragment

Intent
▪ Intent is used to invoke components
▪ “intention” to do some work
▪ Intents can be used to perform the following tasks:
• Broadcast a message.
• Start a service.
FUNDAMENTAL COMPONENTS

Intent (Continues…)

• Launch an activity.
• Display a web page or a list of contacts.
• Dial a phone number or answer a phone call.
▪ Intents are not always initiated by application—they’re also used by the system to notify
application of specific events (such as the arrival of a text message).
▪ Intents can be explicit or implicit.
▪ If you simply say that you want to display a URL, the system decides what component will
fulfill the intention.
▪ You can also provide specific information about what should handle the intention.
FUNDAMENTAL COMPONENTS

Content Provider
▪ Content Providers are used to share data between the applications.
▪ Android defines a standard mechanism for applications to share data without exposing the
underlying storage, structure, and implementation through content providers

Service
▪ Service is a background process that can run for a long time.
▪ Android service is a component that is used to perform operations on the background such
as playing music, handle network transactions, interacting content providers etc.
▪ It doesn't has any UI
▪ two types of services:
▪ Local services are components that are only accessible by the application that is hosting
the service.
▪ Remote services are services that are meant to be accessed remotely by other applications
running on the device
FUNDAMENTAL COMPONENTS

Broadcast receiver

▪ Broadcast receiver is an Android component which allows you to send or receive Android
system or application events. .
▪ All registered receivers for an event are notified by the Android runtime once this event
happens.
▪ For example, applications can register for various system events like boot complete or
battery low, and Android system sends broadcast when specific event occur.
▪ Applications can also initiate broadcasts to let other applications know that some data has
been downloaded to the device and is available for them to use, so this is broadcast
receiver who will intercept this communication and will initiate appropriate action.
FUNDAMENTAL COMPONENTS

[Link]
▪ Defines the contents and behavior of your application
▪ It contains information about activities, content providers, permissions etc.
▪ For example, it lists your application’s activities and services, along with the permissions
and features the application needs to run.
ANDROID VIRTUAL DEVICES (AVD)

▪ AVD is a device configuration that is run with the android emulator


▪ It is an emulator configuration that allows developers to test the application by simulating
the real device capabilities.
▪ It works with the emulator to provide a virtual device-specific environment in which to
install and run Android apps.
▪ In computing, an emulator is hardware or software that enables one computer
system(host) to behave like another computing system(guest)
▪ Emulator enables the host system to run software or use peripheral devices designed for
the guest system
CREATING AVD
▪ The AVD Manager is a tool you can use to create update, delete, repair, and manage
Android virtual devices (AVDs), which define device configurations for the Android
Emulator.
▪ To open the AVD Manager, do one of the following:
• Select Tools →AVD Manager.
• Click AVD Manager icon in the toolbar.
• In the your virtual devices screen click create Virtual device
CREATING AVD
• In the select hardware screen select a hardware profile, and then click Next.
• If you don't see the hardware profile you want, you can create or import a hardware
profile.
CREATING AVD
• In the System Image screen select the system image for a particular API level, and then
click Next .
• x86 images run the fastest in the emulator.
CREATING AVD
• Verify the configuration settings and then finish
RUN THE APP FROM ANDROID STUDIO
▪ To run an app in Android Studio, you can click the green arrow in the menu bars at the top:

▪ Or you can click the Run menu, then select Run

▪ In the select deployment target window, select emulator and click OK


RUN THE APP FROM ANDROID STUDIO
▪ In the select deployment target window, select emulator and click OK
RUNNING ON REAL DEVICES
▪ To run android on real device
• Enable USB debugging from settings → developer options
• Connect device with development machine with USB and after that allow USB
debugging message shown on your device and press OK.
RUNNING ON REAL DEVICES
• After that Go to the menu bar and Run app
RUNNING ON REAL DEVICES
• If real device is connected to your system then it will show Online.

• Now click on your Mobile phone device and click OK


• Studio installs the app on device and starts it
ANDROID APPLICATION FILE STRUCTURE
▪ Android application contains different
components such as java source code, string
resources, images, manifest file, apk file etc.
▪ Let's understand the project structure of android
application.

❑ Modules
▪ Module is a collection of source files and build
settings that allow to divide the project into
discrete units of functionality
1. Android app module
• Provides a container for app’s source code,
resource files, and app level settings like
module level build file and Android Manifest
file
• Major sub divisions are: Manifest, java, Res.
1. [Link]

▪ Every project in Android includes a manifest file, which is [Link], stored in the
root directory of its project hierarchy
▪ It defines the structure and metadata of our application, its components, and its
requirements.
▪ This file includes nodes for each of the Activities, Services, Content Providers and Broadcast
Receiver that make the application and using Intent Filters and Permissions, determines how
they co-ordinate with each other and other applications.

2. Java
▪ The Java folder contains the Java source code files.
▪ These files are used as a controller for controlled UI (Layout file).
▪ It gets the data from the Layout file and after processing that data output will be shown in
the UI layout.
▪ It works on the backend of an Android application.
3. Res

▪ Resource folder is the most important folder because it contains all the non-code sources
like images, XML layouts, UI strings for our android application
▪ Major subdivisions are:
o Drawable: A Drawable folder contains resource type file (something that can be drawn).
Drawable may take a variety of file like Bitmap (PNG, JPEG), Nine Patch, Vector (XML),
Shape, Layers, States, Levels, and Scale.
o Layout: Defines the visual structure for a user interface, such as the UI for an Android
application. This folder stores Layout files that are written in XML language.
o Mipmaps: contains [Link] files to define icons which are used to show on the
home screen.
o Values: Values folder contains a number of XML files like strings, dimens, colors and
styles definitions.
• [Link]: contains color resources of the Android application. Different color values
are identified by a unique name that can be used in the Android application program.
• [Link]: contains string resources of the Android application. The different string
value is identified by a unique name that can be used in the Android application
program. This file also stores string array by using XML language.
• [Link]: The [Link] file contains resources of the theme style in the Android
application. This file is written in XML language.

❑ Gradle script

▪ Gradle is a build system (open source) which is used to automate building, testing,
deployment etc. “[Link]” are scripts where one can automate the tasks
▪ Every Android project needs a gradle for generating an apk from the .java and .xml files in
the project.
▪ A gradle takes all the source files (java and XML) and apply appropriate tools, e.g., converts
the java files into dex files and compresses all of them into a single file known as apk that is
actually used.
▪ Two types of [Link] scripts: Top-level [Link] and Module-level [Link]
FRAGMENT
▪ When a screen is large, it becomes difficult to manage all of its functionality in a single
activity.
▪ Fragments are like sub-activities, and an activity can display one or more fragments on the
screen at the same time.
▪ When a screen is small, an activity contain just one fragment

INTENT
▪ Intent is used to invoke components
▪ “intention” to do some work
▪ Intents can be used to perform the following tasks:
o Broadcast a message.
o Start a service.
o Launch an activity.
o Display a web page or a list of contacts.
o Dial a phone number or answer a phone call.
▪ Intents are not always initiated by application—they’re also used by the system to notify
application of specific events (such as the arrival of a text message).
▪ Intents can be explicit or implicit.
▪ If you simply say that you want to display a URL, the system decides what component will
fulfill the intention.
▪ You can also provide specific information about what should handle the intention.

CONTENT PROVIDER

▪ Content Providers are used to share data between the applications.


▪ Android defines a standard mechanism for applications to share data without exposing the
underlying storage, structure, and implementation through content providers
SERVICE
▪ Service is a background process that can run for a long time.
▪ Android service is a component that is used to perform operations on the background such
as playing music, handle network transactions, interacting content providers etc.
▪ It doesn't has any UI
▪ two types of services:
▪ Local services are components that are only accessible by the application that is hosting the
service.
▪ Remote services are services that are meant to be accessed remotely by other applications
running on the device

BROADCAST RECEIVER
▪ Broadcast receiver is an Android component which allows you to send or receive Android
system or application events. .
▪ All registered receivers for an event are notified by the Android runtime once this event
happens.
▪ For example, applications can register for various system events like boot complete or
battery low, and Android system sends broadcast when specific event occur.
▪ Applications can also initiate broadcasts to let other applications know that some data has
been downloaded to the device and is available for them to use, so this is broadcast receiver
who will intercept this communication and will initiate appropriate action.

[Link]
▪ Defines the contents and behavior of your application
▪ It contains information about activities, content providers, permissions etc.
▪ For example, it lists your application’s activities and services, along with the permissions and
features the application needs to run.
ANDROID APPLICATION LIFE CYCLE

▪ The phases that an application goes through from start to end is called application life cycle
▪ An android application is a collection of activities and an activity corelates to a screen
▪ Each Android application runs inside its own instance of a Virtual Machine (VM)
▪ At any point in time several parallel VM instances could be active
▪ Unlike a common Windows or Unix process, an Android application does not completely
control the completion of its lifecycle.
▪ Every android application should be prepared for untimely termination
▪ Occasionally hardware resources may become critically low and the OS could order early
termination of any process .
▪ The decision considers factors such as:
1. Number and age of the application’s components currently running
2. relative importance of those components to the user
3. how much free memory is available in the system.
▪ To manage limited system resources the Android system can terminate running applications.
▪ If the Android system needs to terminate processes it follows the following priority system.
▪ All processes in the empty list are added to a least recently used list (LRU list).
▪ The processes which are at the beginning of this lists will be the ones killed by the out-of-
memory killer.
▪ If an application is restarted by the user, its gets moved to the end of this queue.
STATES OF AN ACTIVITY
1. Active State
▪ When an Activity is in active state, it means it is active and running.
▪ It is visible to the user and the user is able to interact with it.
▪ Process state is foreground
▪ Android Runtime treats the Activity in this state with the highest priority and never tries to
kill it.
2. Paused State
▪ An activity being in this state means that the user can still see the Activity in the background
such as behind a transparent window or a dialog box ie. it is partially visible.
▪ The user cannot interact with the Activity until he/she is done with the current view.
▪ Process state is visible
▪ Android Runtime usually does not kill an Activity in this state but may do so in an extreme
case of resource crunch.
3. Stopped State
▪ When a new Activity is started on top of the current one or when a user hits the Home key,
the activity is brought to Stopped state.
▪ The activity in this state is invisible, but it is not destroyed.
▪ Process state is background
▪ Android Runtime may kill such an Activity in case of resource crunch.

4. Destroyed State
When a user hits a Back key or Android Runtime decides to reclaim the memory allocated to an
Activity i.e in the paused or stopped state, It goes into the Destroyed state.
The Activity is out of the memory and it is invisible to the user.
LIFE CYCLE METHODS
▪ When the Activity comes back to focus from the paused state, onResume() is invoked.
▪ When we reopen any app(after pressing Home key), Activity now transits from stopped state
to the active state.
▪ Thus, onStart() and onResume() methods are invoked.
• Note: onCreate() method is not called, as it is executed only once during the Activity life-
cycle.
▪ To destroy the Activity on the screen, we can hit the Back key.
▪ This moves the Activity into the destroyed state.
▪ During this event, onPause(), onStop() and onDestroy() methods are invoked.
▪ Whenever we change the orientation of the screen i.e from portrait to landscape or vice-
versa, lifecycle methods start from the start i.e from onCreate() method.
▪ This is because the complete spacing and other visual appearance gets changed and
adjusted.

You might also like