CH 1
CH 1
Applications
Development
https://www.android.com/what-is-android/
History of Android
from 2008-2023
Name Version number release date
3. Eclipse
4. Vysor
5. FlowUp
6. Stetho
7. GameMaker Studio
8. Gradle
12. LeakCanary
13. Unity 3D
14. NimbleDroid
15. Instabug
Android
Framework
Layers
1. Applications
2. Application framework
3. Libraries and Android runtime
4. Linux Kernel
Linux Kernel
This provides a level of abstraction between the device hardware and it
contains all the essential hardware drivers like camera, keypad, display etc.
Also, the kernel handles all the things that Linux is really good such as
networking and a vast array of device drivers, which take the pain out of
interfacing to peripheral hardware.
• Device drivers
• Memory management
• Process management
• Networking
Libraries
• Surface manager – Handling UI Windows
• C/C++ libraries
• Interface through Java
• 2D and 3D graphics
• Media codecs, SQLite, Browser engine
android.app − Provides access to the application model and is the cornerstone of all Android
applications.
android.content − Facilitates content access, publishing and messaging between applications and
application components.
android.database − Used to access data published by content providers and includes SQLite
database management classes.
android.opengl − A Java interface to the OpenGL ES 3D graphics rendering API.
android.os − Provides applications with access to standard operating system services including
messages, system services and inter-process communication.
android.text − Used to render and manipulate text on a device display.
android.view − The fundamental building blocks of application user interfaces.
android.widget − A rich collection of pre-built user interface components such as buttons, labels,
list views, layout managers, radio buttons etc.
android.webkit − A set of classes intended to allow web-browsing capabilities to be built into
applications.
FreeType is a popular software development library used to render text onto bitmaps, and provides
support for other font-related operations. The FreeType font rasterization engine is free and open-
source software with the source code.
Android Runtime
This section provides a key component called Dalvik Virtual Machine which is a
kind of Java Virtual Machine specially designed and optimized for Android.
The Dalvik VM makes use of Linux core features like memory management and
multi-threading etc. The Dalvik VM enables every Android application to run in its
own process, with its own instance of the Dalvik virtual machine.
The Android runtime also provides a set of core libraries which enable Android
application developers to write Android applications using standard Java
programming language.
Application Framework
• Activity Manager − Controls all aspects of the application lifecycle and
activity stack.
• Content Providers − Allows applications to publish and share data with
other applications.
• Resource Manager − Provides access to non-code embedded resources
such as strings, color settings and user interface layouts.
• Notifications Manager − Allows applications to display alerts and
notifications to the user.
• View System − An extensible set of views used to create application user
interfaces.
• Android Windows Manager is basically a file manager, which allows you to
manage files in multiple windows.
Applications
APK: Android Application Package. File Extension: .apk. An APK file is the file
format used to install the applications on android
DALVIK RUNTIME…..
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.
16
Android applications are
compiled to Dalvik
bytecode
Write app in Java
Compiled in Java
Linux OS
Application Building Blocks
Application components are the essential building blocks of an Android
application. There are following four main components that can be used
within an Android application −
1 Activities
They dictate the UI and handle the user interaction to the
smart phone screen.
Services
2 They handle background processing associated with an
application.
Broadcast Receivers
3 They handle communication between Android OS and
applications.
Content Providers
4 They handle data and database management issues.
ACTIVITIES
An activity represents a single screen with a user interface,
in-short Activity performs actions on the screen. For
example, an email application might have one activity that
shows a list of new emails, another activity to compose an
email, and another activity for reading emails. If an
application has more than one activity, then one of them
should be marked as the activity that is presented when
the application is launched.
An activity is implemented as a subclass of Activity class
as follows −
public class MainActivity extends Activity {
}
SERVICES
A service is a component that runs in the background to perform long-running
operations. For example, a service might play music in the background while
the user is in a different application, or it might fetch data over the network
without blocking user interaction with an activity.
res/drawable
2 This is a directory for drawable objects that are designed for high-density
screens.
res/layout
3 This is a directory for files that define your app's user interface.
res/values
4 This is a directory for other various XML files that contain a collection of
resources, such as strings and colours definitions.
AndroidManifest.xml
5 This is the manifest file which describes the fundamental characteristics of the
app and defines each of its components.
Build.gradle
This is an auto generated file which contains compileSdkVersion,
6
buildToolsVersion, applicationId, minSdkVersion, targetSdkVersion, versionCode
and versionName
THE MAIN ACTIVITY FILE
package com.example.myapplication;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
THE MANIFEST FILE
Whatever component you develop as a part of your application, you
must declare all its components in a manifest.xml which resides at the
root of the application project directory. This file works as an interface
between Android OS and your application, so if you do not declare your
component in this file, then it will not be considered by the OS. For
example, a default manifest file will look like as following file −
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myapplication">
<application
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/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>
THE LAYOUT FILE
The activity_main.xml is a layout file available in res/layout
directory, that is referenced by your application when
building its interface. You will modify this file very frequently
to change the layout of your application. For your "Hello
World!" application, this file will have following content
related to default layout −
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
RUNNING THE
APPLICATION
To run the app from Android
studio, click Run Icon from the
tool bar. Android studio installs
the app on your AVD and starts
it and if everything is fine with
your set-up and application, it
will display following Emulator
window −
Questions & answers