0% found this document useful (0 votes)
44 views47 pages

Application Development With Android Operating System

Android is an open source mobile operating system based on Linux. It allows developers to build customizable applications for smartphones and tablets. The Android architecture consists of five main components - the Linux kernel, native libraries, Android runtime, application framework, and applications. Activities, services, content providers, broadcast receivers, and fragments are the core building blocks that applications use to create user interfaces and perform tasks. Developers can use an Android Virtual Device and DDMS for debugging applications without needing a physical device.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views47 pages

Application Development With Android Operating System

Android is an open source mobile operating system based on Linux. It allows developers to build customizable applications for smartphones and tablets. The Android architecture consists of five main components - the Linux kernel, native libraries, Android runtime, application framework, and applications. Activities, services, content providers, broadcast receivers, and fragments are the core building blocks that applications use to create user interfaces and perform tasks. Developers can use an Android Virtual Device and DDMS for debugging applications without needing a physical device.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 47

Chapter Two:

Application Development with Android


Operating System
What is Android ?

 ANDROID is one of the most widely used mobile OS these


days. 
 Is a mobile operating system developed by Google, based on
the Linux kernel 
 Designed primarily for touchscreen mobile devices such
as smartphones and tablets.
 Android is open source, meaning developers can modify and
customize the OS for each phone

2
 Introduced by open handset alliance (OHA) in Nov,2007

 The Android platform is Google Inc.'s open and free


software stack that includes an
– operating system,
– middleware and also
– key applications for use on mobile devices, including
smartphones. 

 NB: Android is the nick name of Andy Rubin given by


coworkers because of his love to robots.
3
Why Android ?

 Android powers millions of mobile devices all


around the world.
 It's the largest installed base of any mobile
platform and growing fast.
 Every day more than 1 million new Android
devices are activated worldwide.
4
 A flexible Gradle-based build system

 A fast and feature-rich emulator

 A unified environment where you can develop for all Android

devices

 Instant Run to push changes to your running app without building a

new APK

 Code templates and GitHub integration to help you build common

app features and import sample code


5
 Extensive testing tools and frameworks

 Covering tools to catch performance, usability, version

compatibility, and other problems

 C++ support

 Built-in support for Google Cloud Platform, making it easy

to integrate Google Cloud Messaging and App Engine

6
Features of Android Operating System
 General  Connectivity
– Messaging : SMS, MMS Bluetooth
– Web browser: chrome tethering
– Voice based features  Media
– Multi-touch Streaming media support
– Multitasking Media support: WAV, JPEG,
PNG, GIF, MP3, WEBM
– Screen capture
External storage: USB HDDs,
– Tv recording FAT32
– Video calling  Hardware support:
– accessibility video cameras, touchscreens, 
GPS, accelerometers, gyroscop
es, barometers, 
magnetometers, 7
Categories of Android applications

There are many android applications in the market. The


top categories are:
 Entertainment
 Tools
 Communication
 Productivity
 Personalization
 Music and Audio
 Social
 Media and Video
 Travel and Local etc.
8
Android Architecture

• Categorized into Five parts:-

1. Linux kernel
2. Native libraries (middleware)
3. Android Runtime

4. Application Framework
5. Applications

9
10
1) Linux kernel
• It is the heart of android architecture that exists at the root of
android architecture. 
• Linux kernel is responsible for device drivers, power
management, memory management, device management and
resource access.
2) Native Libraries
• On the top of linux kernel, their are Native libraries such as
WebKit, OpenGL, FreeType, SQLite, Media, C runtime
library (libc) etc.
• The WebKit library is responsible for browser support, SQLite
is for database, FreeType for font support, Media for playing
and recording audio and video formats. 11
3) Android Runtime
• 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.
4) Android Framework
• On the top of Native libraries and android runtime, there is android framework.
Android framework 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.
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.

12
Android Core Building Blocks/Application Components

13
Activity

• An activity is a class that represents a single screen with a user


interface, in-short Activity performs actions on the screen.
• It is like a Frame in AWT
• 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.
• An activity is implemented as a subclass of Activity class as
follows

14
Intent

 Intent is used to invoke components. It is mainly used


to:
– Start the service
– Launch an activity
– Display a web page
– Display a list of contacts
– Broadcast a message
– Dial a phone call etc.

15
Service

 Service is a background process that can run for a long


time.
 A service does not provide a user interface.
 For example, play music in the background while the user
is in a different application
 A service is implemented as a subclass of Service class as
follows

16
Content Provider

• Content Providers are used to share data between the


applications.
• A content provider component supplies data from one
application to others on request. Such requests are
handled by the methods of the ContentResolverclass.
• You can store the data in the file system, an SQLite
database, on the web, or any other persistent storage
location your application can access.
• Through the content provider, other applications can
query or even modify the data (if the content provider
allows it).
17
Broadcast receivers

 A broadcast receiver is a component that responds to


system-wide broadcast announcements.
 Many broadcasts originate from the system
 for example, a broadcast announcing that the screen
has turned off, the battery is low, or a picture was
captured. Applications can also initiate broadcasts.

18
Fragment

 Fragments are like parts of activity. An activity can


display one or more fragments on the screen at the
same time.
AndroidManifest.xml
 It contains information's about activities, content
providers, permissions etc.
 It is like the web.xml file in Java EE.
Install Android 19
Android Virtual Device (AVD)

Android Virtual Device (AVD)


 It is used to test the android application without the need
for mobile or tablet etc. It can be created in different
configurations to emulate different types of real devices.
 Android Emulator is used to run, debug and test the
android application. If you don't have the real device, it
can be the best way to run, debug and test the application.

20
Android Emulator Quick-Start Guide

 Android Virtual Device (AVD)


 Eases the development process by providing an option to test
mobile applications on various virtual devices.

 So lets see how to create a new emulator to test our


application

21
Create a new Emulator
 Open Android Studio and start AVD manager located
in Tools > Android > AVD Manager

22
Con’t….
 The AVD Manager will load the list of already installed
system images (if any)
 provide you an option to create new emulator via Create
Virtual Device button

23
Con’t…
 Select Hardware screen. A list of device definitions will
load. Choose the preferred device from the Phone tab and
press Next.

24
Con’t…
 Then you get list of available system images
 To be able to create an emulator, the system image must be
downloaded locally.
 Press Download to obtain the image

25
Con’t…
 Once the system image is successfully downloaded and
unzipped, press Finish.

26
Con’t…
 The System Image screen will appear again with the
downloaded system image. Select the system image and
press Next.

27
Con’t…
 The final configuration screen will load. When all settings
are set and ready press Finish.

28
Con’t…
 The newly created Android Virtual Device is now listed in
the AVD Manager.
 Select the system image and press the green arrow to the
right to manually start the emulator.

29
Android DDMS Quick-Start Guide

 The Dalvik Debug Monitor Server (DDMS) is a debugging tool


provided with the Android Software Development Kit (SDK).
 Developers use DDMS to provide a window into the emulator or
the actual device for debugging purposes as well as file and
process management.
 It’s a blend of several tools: a task manager, a profiler, a file
explorer, an emulator console, and a logging console.
 If you use the Android IDE, the DDMS tool is tightly integrated
with your development environment as a perspective.
30
31
Android Debug Bridge Quick-Start Guide
 Android Debug Bridge, is a command-line utility included
with Google's Android SDK. 
 can control your device over USB from a computer, copy
files back and forth, install and uninstall apps, run shell
commands, and more
 Android Debug Bridge (adb) is a versatile command-line
tool that lets you communicate with a device.
 It is a client-server program that includes three
components:
• Client
• Daemon
• Server
32
Con’t…
– A client, which sends commands. The client runs on your
development machine.
– A daemon (adbd), which runs commands on a device. The
daemon runs as a background process on each device.
– A server, which manages communication between the client
and the daemon. The server runs as a background process on
your development machine
 Android Studio does not contain ADB, you need Android SDK for
it (it is installed on first run of Android Studio 0.9.x and newer). 
 ADB is located in sdk\platform-tools .
 It's possible to add to PATH in Windows and use Terminal
inside Android Studio only by command:
 adb shell and after use get root shell.
33
Enable adb debugging on your device

 Enable USB debugging in the device system settings,


under Developer options.
 On Android 4.2 and higher, the Developer options screen is
hidden by default. To make it visible, go to Settings > About
phone and tap Build number seven times.
 You can now connect your device with USB.

 You can verify that your device is connected by executing adb


devices from the android_sdk/platform-tools/ directory.
 If connected, you'll see the device name listed as a "device."
34
Android Studio IDE Tips and Tricks

 Magic security check : to follow the standard IDE recommendations


while coding!
 Quick feature search: Ctrl+Shift+A
 Reveal usage: Alt+F7[to know where a certain variable is used, Press
Escape when you’re done]
 Keep the log on application crash
 Code without distractions: View → Enter Distraction Free Mode, in
which the editor will go full screen
 Auto indent stuff: Pasted code from somewhere Simply press Ctrl+Alt+I
35
Con’t…

 Follow a consistent code style:


– Preferences → Code Style → Java and create your own style
that the IDE can enforce.

 Get better with Git

 Count the methods:


– Android Methods Count 

 Convert strings to resources:  


– Alt+Enter, and simply enter a resource name to finish the process!
36
Activating Components
 A unique aspect of the Android system design is that any
application can start another application’s component.
 Three of the four component types—activities, services, and
broadcast receivers—are activated by an asynchronous message
called an intent.

37
Project Structure

 Each project in Android Studio contains one or more


modules with source code files and resource files.
 Android app modules

 Library modules

 Google App Engine modules


 By default, Android Studio displays your project files in the
Android project view.

38
Con’t…

 All the build files are visible at the top level under Gradle
Scripts and each app module contains the following folders:
– manifests: Contains the AndroidManifest.xml file.
– java: Contains the Java source code files, including JUnit
test code.
– res: Contains all non-code resources, such as XML
layouts, UI strings, and bitmap images.

39
40
The Manifest File
 Your application must declare all its components in this
file, which must be at the root of the application project
directory.
 The manifest does a number of things in addition to
declaring the application's components, such as:
– Identify any user permissions the application requires
– Declare the minimum API Level required by the application
– Declare hardware and software features used or required by
the application
– API libraries the application needs to be linked against

41
Declaring Components
 The primary task of the manifest is to inform the system about the
application's components. For example, a manifest file can declare an
activity as follows:

 Activities, services, and content providers that you include in your source
but do not declare in the manifest are not visible to the system and,
consequently, can never run.
42
Con’t
 Android Projects
– An application project is the main type of project and the
contents are eventually built into an .apk file that you install
on a device.
 Test Projects
– These projects contain code to test your application projects
and are built into applications that run on a device.
 Library Projects
– These projects contain shareable Android source code and
resources that you can reference in Android projects.
– Library projects cannot be installed onto a device, however,
they are pulled into the .apk file at build time.
43
res
 Contains application resources, such as
– drawable files,
– layout files, and string values

44
Security
 The Android operating system is a multi-user Linux system in
which each application is a different user.
 Each process has its own virtual machine (VM), so an
application's code runs in isolation from other applications.
 An application can request permission to access device data
such as the user's contacts, SMS messages, the mountable
storage (SD card), camera, Bluetooth, and more.
 All application permissions must be granted by the user at install
time.
45
Build Process

46
Android Versions

47

You might also like