Mobile App Development Overview Guide
Mobile App Development Overview Guide
Development
UNIT-I
Topics
Chapter 1: Java FX Technology
• Introduction to MAD
• Trends,
• Various platforms,
• Introduction to smart phones
Chapter 2:
• Android platform features and architecture
• Versions
• ART(Android Runtime)
• ADB(Android Debug Bridge).
Chapter 3:
• Android studio and its working environment
• Gradle build system
• Emulator setup
• Application Framework Basics
-Resources , layout, values,
-Asset XML representation and
-Generated [Link] , Android manifest file.
-Creating a simple application
JavaFX Technology
• JavaFX is a Java library used to develop Desktop applications
as well as Rich Internet Applications (RIA). The applications
built in JavaFX, can run on multiple platforms including Web,
Mobile and Desktops.
• JavaFX also provides its own components and doesn't
depend upon the operating system.
• integrated the features of a mobile phone and a personal digital assistant (PDA)
for managing calendars and contacts. Both were much larger than regular
phones.
• It wasn’t until 2000 that the first real smartphone, the Ericsson R380, was
released.
• It wasn’t any larger than a regular phone, and in the early 2000s many others
followed suit, with phones like the Palm and BlackBerry achieving big success.
• In 2007, Apple released the iPhone, which eschewed hardware buttons for full
touchscreen control and has been the template for smartphones ever since
A Smartphone can:
• Make voice calls
• Make video calls
• Access the internet and browse the web
• Take photos, and upload them to the web
• Navigate with GPS if the phone has GPS built-in
• Play back music and video stored on the phone
• Manage your contacts and appointments
• Send emails
• Play in-built games
• Run new applications and games downloaded from the
internet
ANDROID PLATFORM
Introduction
• Android is a open source linux based
operating system intended for mobile
computing platforms.
• It is a software stack for mobile operating
system.
• Android is under development by Google and
OHA(Open Handset Alliance)
OHA includes several Companies
• Android is a complete set of software for
mobile devices such as tablet computers,
notebooks, smart phones, electronic book
readers, set-top boxes etc
• The Android Platform was launched in 2007 by
the Open Handset Alliance, an alliance of
prominent companies that includes Google,
HTC, Motorola, Texas Instruments and others.
• the applications that run on the Android
Platform are written in Java, there is no Java
Virtual Machine(JVM). Instead, the Java classes
are first compiled into what are known as
Dalvik Executables and run on the Dalvik
Virtual Machine(DVM).
• To create an application for the platform, a
developer requires the Android SDK, which
includes tools and APIs.
• The SDK is supported in many environments including
Linux, Windows, and OS X and can be downloaded
free from [Link] [Link].
• It contains a linux-based Operating
System, middleware and key mobile applications.
• It can be thought of as a mobile operating system.
But it is not limited to mobile only. It is currently used
in various devices such as mobiles, tablets, televisions
etc.
History of Android
1) Initially, Andy Rubin founded Android
Incorporation in Palo Alto, California, United
States in October, 2003.
2) In 17th August 2005, Google acquired android
Incorporation. Since then, it is in the subsidiary
of Google Incorporation.
3) The key employees of Android Incorporation
are Andy Rubin, Rich Miner, Chris
White and Nick Sears.
4) Originally intended for camera but shifted to
smart phones later because of low market for
camera only.
5) Android is the nick name of Andy Rubin given by
coworkers because of his love to robots.
6) In 2007, Google announces the development of
android OS( Android Beta SDK released 12th Nov).
7) In 2008, HTC launched the first android mobile.
Android Features
• Messaging
– SMS and MMS
• Web browser
– Based on the open-source WebKit layout engine,
coupled with Chrome's V8 JavaScript engine
supporting HTML5 and CSS3.
• Multi-touch
– Supports multi-touch screens
Android Features
• Multitasking
– User can jump from one task to another and same
time various application can run simultaneously.
• Multiple language support
– Location Specific language and culture can be
adopted
• Connectivity
– GSM/EDGE, IDEN, CDMA, EV-DO, UMTS,
Bluetooth, Wi-Fi, LTE, NFC and WiMAX.
Android Features
• Media support
– H.263, H.264, MPEG-4 SP, AMR, AMR-WB, AAC, HE-AAC, AAC 5.1,
MP3, MIDI, Ogg Vorbis, WAV, JPEG, PNG, GIF, and BMP.
• External storage
– SQLite, a lightweight relational database, is used for data storage
purposes.
Tethering — Supports sharing of Internet connections as a
wired/wireless hotspot
• Flash support — Android 2.3 supports Flash [Link]
• Streaming media support
• Includes support for the following media: H.263, H.264 (in 3GP
or MP4 container), MPEG-4 SP, AMR, AMR-WB (in 3GP
container), AAC, HE-AAC (in MP4 or 3GP container), MP3,
MIDI, Ogg Vorbis, WAV, JPEG, PNG, GIF, and BMP
Android Features
• Media support — Includes support for the
following media: H.263, H.264 (in 3GP or MP4
container), MPEG-4 SP, AMR, AMR-WB (in 3GP
container), AAC, HE-AAC (in MP4 or 3GP
container), MP3, MIDI, Ogg Vorbis, WAV, JPEG,
PNG, GIF, and BMP
• Hardware support — Accelerometer Sensor,
Camera, Digital Compass, Proximity Sensor,
and GPS
Android Versions, Codename and AP
➤ Linux kernel — This is the kernel on which Android is based. This layer contains all the low level device
drivers for the various hardware components of an Android device.
➤ Libraries — These contain all the code that provides the main features of an Android OS. For example,
the SQLite library provides database support so that an application can use it for data storage. The
WebKit library provides functionalities for web browsing.
➤ Android runtime — At the same layer as the libraries, the Android runtime provides a set of core
libraries that enable developers to write Android apps using the Java programming language. The
Android runtime also includes the Dalvik virtual machine, which enables every Android application to run
in its own process, with its own instance of the Dalvik virtual machine (Android applications are compiled
into Dalvik executables). Dalvik is a specialized virtual machine designed specifi cally for Android and
optimized for battery-powered mobile devices with limited memory and CPU.
➤ Application framework — Exposes the various capabilities of the Android OS to application developers so
that they can make use of them in their applications.
➤ Applications — At this top layer, you will find applications that ship with the Android device (such as
Phone, Contacts, Browser, etc.), as well as applications that you download and install from the Android
Market. Any applications that you write are located at this layer.
Linux kernel
• At the bottom of the layers is Linux - Linux 3.6
with approximately 115 patches.
• This provides a level of abstraction between the
device hardware and Operating System. it
contains all the essential hardware drivers like
camera, keypad, display etc.
• Also, the kernel handles all the things that Linux
is really good at such as networking and a vast
array of device drivers.
Hardware Abstraction Layer (HAL)
• The hardware abstraction layer (HAL) provides standard
interfaces that expose device hardware capabilities to
the higher-level Java API framework.
• The HAL consists of multiple library modules, each of
which implements an interface for a specific type of
hardware component, such as the camera or bluetooth
module. When a framework API makes a call to access
device hardware, the Android system loads the library
module for that hardware component.
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:text="Activity1" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="open Activity2" />
</RelativeLayout>
[Link]
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="[Link]
xmlns:app="[Link]
xmlns:tools="[Link]
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:text="Activity2" />
</RelativeLayout>
[Link]
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
Button b;
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_main);
b= (Button)findViewById([Link]);
[Link](new [Link]() {
@Override public void openActivity2()
public void onClick(View v) {
openActivity2();
{
} Intent i=new Intent(this,[Link]);
}); startActivity(i);
} }
}
[Link]
package [Link];
import [Link];
import [Link];
@Override
protected void onCreate(Bundle savedInstanceState) {
[Link](savedInstanceState);
setContentView([Link].activity_2);
}
}
Output
Gradle Build System
Gradle Build System cont..
• Android Studio uses Gradle, an advanced
build toolkit, to automate and manage
the build process, while allowing you to
define flexible custom build configurations.
• Each build configuration can define its
own set of code and resources, while
reusing the parts common to all versions
of your app.
Gradle Build System cont..
android {
compileSdk 31
defaultConfig {
applicationId "[Link]"
minSdk 21
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "[Link]"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('[Link]'),
'[Link]'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation '[Link]:appcompat:1.3.1'
implementation '[Link]:material:1.4.0'
implementation '[Link]:constraintlayout:2.1.1'
testImplementation 'junit:junit:4.+'
androidTestImplementation '[Link]:junit:1.1.3'
androidTestImplementation '[Link]:espresso-core:3.4.0'
}
• The Module-level [Link] supports various build configurations like:
1. android: This block is used for configuring the specific android build options.
1. compileSdkVersion – This is used to define the API level of the app and the app can
use the features of this and lower level.
2. defaultConfig:
1. applicationId– This is used for identifying unique id for publishing of the app.
2. minSdkVersion– This defines the minimum API level required to run the
application.
3. targetSdkVersion– This defines the API level used to test the app.
4. versionCode– This defines the version code of the app. Every time an update needs
to be of the app, the version code needs to be increased by 1 or more.
5. versionName– This defines the version name for the app. this could be increased
by much while creating an update.
3. buildTypes(release):
1. minifyEnabled– this will enable code shrinking for release build.
2. proguardFiles– this will specify the progaurd settings file.
4. dependencies: This specifies the dependencies that are needed to build the
project.
• Both the top-level and module-level [Link] files are the main script files
for automating the tasks in an android project and are used by Gradle for
generating the APK from the source files.
Emulator Setup
• The emulator lets you prototype, develop and test
Android applications without using a physical device.
• Creating AVD
– If you want to emulate a real device, first crate an AVD
with the same device configurations as real device, then
launch this AVD from AVD manager.
• Changing Orientation
– Usually by default when you launch the emulator, its
orientation is vertical, but you can change it orientation
by pressing Ctrl+F11 key from keyboard.
To start the emulator:
[Link] the AVD Manager.
[Link]-click an AVD, or click Run
[Link] Android Emulator loads.
• While the emulator is running, you can run
Android Studio projects and choose the
emulator as the target device.
Emulator Commands
• Home - Shifts to main screen
• F2 - Toggles context sensitive menu
• F3 - Bring out call log
• F4 - End call
• F5 - Search
• F6 - Toggle trackball mode
• F7 - Power button
• F8 - Toggle data network
• Ctrl+F5 - Ring Volume up
• Ctrl+F6 - Ring Volume down
Android Frame work Basics
• Resorses
• Layouts
• Values
Apart from coding for the application, we can take care
of various other resources like static content that your
code uses, such as bitmaps, colors, layout definitions,
user interface strings, animation instructions, and more.
These resources are always maintained separately in
various sub-directories under res/ directory of the
project.
Directory structure of an android application
MyProject/
app/
manifest/
[Link]
java/
[Link]
res/
drawable/
[Link]
layout/
activity_main.xml [Link]
values/
[Link]
Resources
Animation Resources
Define pre-determined animations.
Tween animations are saved in res/anim/ and accessed from the [Link] class.
Frame animations are saved in res/drawable/ and accessed from the [Link] class.
Color State List Resource
Define a color resources that changes based on the View state.
Saved in res/color/ and accessed from the [Link] class.
Drawable Resources
Define various graphics with bitmaps or XML.
Saved in res/drawable/ and accessed from the [Link] class.
Layout Resource
Define the layout for your application UI.
Saved in res/layout/ and accessed from the [Link] class.
Menu Resource
Define the contents of your application menus.
Saved in res/menu/ and accessed from the [Link] class.
String Resources
Define strings, string arrays, and plurals (and include string formatting and styling).
Saved in res/values/ and accessed from the [Link], [Link], and [Link] classes.
Style Resource
Define the look and format for UI elements.
Saved in res/values/ and accessed from the [Link] class.
Font Resources
Define font families and include custom fonts in XML.
Saved in res/font/ and accessed from the [Link] class.
Android - UI Layouts
Android - UI Layouts
Android - UI Layouts –Example code
Android Layout Types
• Linear Layout is a view group that aligns all children in
a single direction, vertically or horizontally.
• Relative Layout is a view group that displays child
views in relative positions.
• Table Layout is a view that groups views into rows and
columns.
• Absolute Layout enables you to specify the exact
location of its children.
• Frame Layout is a placeholder on screen that you can
use to display a single view.
Android Layout Types
• List View is a view group that displays a list of
scrollable items.
• Grid View is a View Group that displays items
in a two-dimensional, scrollable grid.
Layout Attributes
• android:id - This is the ID which uniquely identifies the view.
• android:layout_width - This is the width of the layout.
• android:layout_height - This is the height of the layout
• android:layout_marginTop - This is the extra space on the top
side of the layout.
• android:layout_marginBottom - This is the extra space on the
bottom side of the layout.
• android:layout_marginLeft - This is the extra space on the left
side of the layout.
• android:layout_marginRight - This is the extra space on the
right side of the layout.
Layout Attributes
• android:layout_gravity - This specifies how child Views
are positioned.
• android:layout_weight - This specifies how much of the
extra space in the layout should be allocated to the View.
• android:layout_x - This specifies the x-coordinate of the
layout.
• android:layout_y - This specifies the y-coordinate of the
layout.
• android:layout_width - This is the width of the layout.
• android:layout_width - This is the width of the layout.
Layout Attributes
• android:paddingLeft - This is the left padding
filled for the layout.
• android:paddingRight - This is the right
padding filled for the layout.
• android:paddingTop - This is the top padding
filled for the layout.
• android:paddingBottom - This is the bottom
padding filled for the layout.
values
• XML files that contain simple values, such as strings, integers, and
colors.
For example, here are some filename conventions for resources you
can create in this directory −
o [Link] for resource arrays, and accessed from the [Link] class.
o [Link] for resource integers, and accessed from
the [Link] class.
o [Link] for resource boolean, and accessed from the [Link] class.
o [Link] for color values, and accessed from the [Link] class.
o [Link] for dimension values, and accessed from the [Link] class.
o [Link] for string values, and accessed from the [Link] class.
o [Link] for styles, and accessed from the [Link] class.
Assets
• Assets provide a way to add arbitrary files like text, XML, HTML, fonts,
music, and video in the application.
• If one tries to add these files as “resources“, Android will treat them
into its resource system and you will be unable to get the raw data.
• In Android one can store the raw asset file like JSON, Text, mp3, HTML,
pdf, etc in two possible locations:
• assets
• res/raw folder
Both of them appears to be the same, as they can read the file and
generate InputStream as below
• From assets
[Link](assetPathFilename)
• From res/raw
[Link](resourceRawFilename)
Asset vs Raw Folder
XML representation
• XML stands for Extensible Mark-up Language.
• XML is a very popular format and commonly
used for sharing data on the internet.
• Android provides three types of XML parsers
which are DOM,SAX and XMLPullParser.
• Among all of them android recommend
XMLPullParser because it is efficient and easy
to use.
XML representation
• The first step is to identify the fields in the
XML data in which you are interested in.
• For example. In the XML given below we
interested in getting temperature only.
XML Elements
• Prolog - An XML file starts with a prolog. The first line
that contains the information about a file is prolog
• Events - An XML file has many events. Event could be
like this. Document starts , Document ends, Tag start ,
Tag end and Text e.t.
• Text - Apart from tags and events, and xml file also
contains simple text. Such as GB is a text in the
country tag.
• Attributes - Attributes are the additional properties of
a tag such as value e.t.c
Generated [Link]
• Android [Link] is an auto-generated file by
aapt (Android Asset Packaging Tool) that contains
resource IDs for all the resources of res/ directory.
• If you create any component in the
activity_main.xml file, id for the corresponding
component is automatically created in this file.
• This id can be used in the activity source file to
perform any action on the component.
• It can not be modified by the hand
Generated [Link] for Strings
Android Manifest file
• The [Link] file contains information of the
package, including components of the application such as
activities, services, broadcast receivers, content providers etc.
• It performs some other tasks also:
It is responsible to protect the application to access any
protected parts by providing the permissions.
It also declares the android api that the application is going
to use.
It lists the instrumentation classes. The instrumentation
classes provides profiling and other informations. These
informations are removed just before the application is
published etc.
Example of manifest file
<manifest xmlns:android="[Link]
package="[Link]"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="[Link]" />
<category android:name="[Link]" />
</intent-filter>
</activity>
</application>
</manifest>
Elements of the [Link] file
The elements used in the above xml file are described below.
• <manifest>
manifest is the root element of the [Link] file. It has package attribute that describes the
package name of the activity class.
• <application>
application is the sub element of the manifest. It includes the namespace declaration. This element contains
several sub elements that declares the application component such as activity etc.
The commonly used attributes are of this element are icon, label, theme etc.
android:icon represents the icon for all the android application components.
android:label works as the default label for all the application components.
android:theme represents a common theme for all the android activities.
• <activity>
activity is the sub element of application and represents an activity that must be defined in the
[Link] file. It has many attributes such as label, name, theme, launchMode etc.
• <intent-filter>
intent-filter is the sub-element of activity that describes the type of intent to which activity, service or
broadcast receiver can respond to.
• <action>
It adds an action for the intent-filter. The intent-filter must have at least one action element.
Simple Android Application
Procedure:
1) Open eclipse or android studio and select new android project
2) Give project name and select next
3) Choose the android version. Choose the lowest android
version(Android 2.2)and select next
4) Enter the package name as [Link] and click finish
5) Go to package explorer in the left hand side.
select our project.
6) Go to res folder and select layout. Double click the [Link]
7) Now you can see the Graphics layout window.
8) Click the [Link] file and type the code below
Activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayoutxmlns:android="[Link] android:layout_width="fill_parent"
android:layout_height="fill_parent" android:orientation="vertical" >
<TextViewandroid:id="@+id/textView1" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_margin="20sp" android:gravity="center"
android:text="HELLO WORLD" android:textSize="20sp" android:textStyle="bold" />
<Button android:id="@+id/button1"
android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center"
android:text="Change font size" android:textSize="20sp" />
<Button android:id="@+id/button2"
android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center"
android:text="Change color" android:textSize="20sp" />
<Button android:id="@+id/button3“
android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center"
android:text="Change font" android:textSize="20sp" />
</LinearLayout>