Mad Unit 3

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 60

Mobile Application Development

Unit- 1
Mobile Operating Systems

• A mobile OS is an operating system for smartphones, tablets, PDAs, or other mobile


devices.
• Mobile OSs combine features of a personal computer OS with other features useful for
mobile or handheld use; usually including, and most of the following considered essential in
modern mobile systems;
• touchscreen, cellular, Bluetooth, Wi-Fi, GPS mobile navigation, camera, video camera, speech
recognition, voice recorder, music player, etc.
• Some Current software platforms
• Android (based on the Linux Kernel) is from Google Inc.
• CyanogenMod and Cyanogen OS are based on the open source Android Open Source
Project(AOSP).
• Fire OS is an operating system launched by Amazon based on Google's AOSP.
• iOS (previously known as iPhone OS) is from Apple Inc.
• Windows Phone (Soon to be Windows 10 Mobile) is from Microsoft.
• BlackBerry 10 (based on the QNX OS) is from BlackBerry.
• Firefox OS is from Mozilla.
Introduction to Android

• Android is an OS based on Linux with a Java programming interface. It is a comprehensive


open source platform designed for mobile devices.
• First beta version of Android Software Development Kit (SDK) was released by Google in
2007 where as first commercial version, Android 1.0, was released in September 2008.
• Features of Android
• Beautiful UI, Connectivity, Storage, Media support, Messaging, Web browser, Multi-touch,
Multi-tasking, Resizable widgets, Multi-Language, GCM, Wi-Fi Direct, Android Beam
• Android Applications
• Android applications are usually developed in the Java language using the Android
Software Development Kit.
• Once developed, Android applications can be packaged easily and sold out either through a
store such as Google Play, SlideME, Opera Mobile Store, Mobango, F-droid and the
Amazon Appstore.
Introduction to Android

History of Android
• The code names of android ranges from A to L currently, such as Aestro, Blender, etc…

• Categories of Android applications


Requirements for Android

• OS
• Android application development on either of the following operating systems:
• Microsoft Windows.
• Mac OS X 10.5.8 or later version with Intel chip.
• Linux including GNU C Library 2.7 or later.
• Tools
• All the required tools to develop Android applications are freely available and can be
downloaded from the Web. Following is the list of software's you will need before you start
your Android application programming.
1. Java JDK6 or later version
2. Android Studio / Android SDK and Eclipse IDE for Java Developers (optional) and Android
Development Tools (ADT) Eclipse Plug-in (optional)
Requirements for Android

• Download Android Studio


• From http://developer.android.com/sdk/installing/index.html

• System Requirements for Windows


• Microsoft Windows 7/8/10 (32-bit or 64-bit)
• 3 GB RAM minimum, 8 GB RAM recommended (plus 1 GB for the Android Emulator)
• 2 GB of available disk space minimum, 4 GB recommended (500 MB for IDE plus 1.5 GB for
Android SDK and emulator system image)
• 1280 x 800 minimum screen resolution
• Java Development Kit (JDK) 8
Java JDK

• The Java Development Kit (JDK) is a software development environment used for developing
Java applications and applets.
• It includes the Java Runtime Environment (JRE), an interpreter/loader (java), a compiler
(javac), an archiver (jar), a documentation generator (javadoc) and other tools needed in Java
development.
• JVM
• JVM (Java Virtual Machine) is a specification that provides runtime environment in which
java bytecode can be executed.
• JVMs are available for many hardware and software platforms. JVM is a part of Java Run
Environment (JRE).
• The JVM performs following operation:
• Loads code
• Verifies code
• Executes code
• Provides runtime environment
• JRE
• The Java Runtime Environment (JRE) is a set of software tools for development of Java
applications. It combines the Java Virtual Machine (JVM), platform core classes and
supporting libraries.
Android SDK

• The Android SDK (software development kit) is a set of development tools used to develop
applications for Android platform. The Android SDK includes the following:
• Required libraries
• Debugger
• An emulator
• Relevant documentation for the Android application program interfaces (APIs)
• Sample source code
• Tutorials for the Android OS
Android Development Tools (ADT)

• The android developer tools let you create interactive and powerful application for android
platform.
• 1. Android Studio
• Developed by Google, Android Studio is an all-rounder integrated development
environment. Android has Gradle-base support that has features like visual layout editor,
intelligent code editor, real-time profilers and APK analyzer.
• 2. Visual Studio – Xamarin
• Xamarin was launched in 2011 which is the best free IDE for delivering an enterprise-
quality, cross-platform approach. Xamarin supplies add-ins to Microsoft Visual Studio that
allows developers to build Android, iOS, and Windows apps within the IDE
• 3. IntelliJ IDEA
• Using this IDE, you can do in-depth coding, quick navigation, and error analysis. It supports
mobile app development with the help of Java, Scala, Kotlin, Groovy.
• 4. Eclipse IDE
• It is one of the most popular IDES of Android apps. The open-source software is free to use.
Released under the Eclipse Public License, it holds a large community having plenty of
plugins and configurations. Highly customizable offers full support for Java programming
language and XML.
Android Virtual Devices (AVDs)

• An Android Virtual Device (AVD) is a configuration that defines the characteristics of an


Android phone, tablet, Wear OS, Android TV, or Automotive OS device that you want to
simulate in the Android Emulator.
• The AVD Manager is an interface you can launch from Android Studio that helps you create
and manage AVDs.

• To open the AVD Manager, do one of the following:
• Select Tools > AVD Manager.

• Click AVD Manager in the toolbar.


Create a new AVD

• 1. Open the AVD Manager by clicking Tools > AVD Manager.


Create a new AVD

• 2. Click Create Virtual Device, at the bottom of the AVD Manager dialog. The Select
Hardware page appears.
Create a new AVD
• 3. 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. The System Image page appears.
Create a new AVD

• 4. Select the system image for a particular API level, and then click Next. The Verify
Configuration page appears.
Create a new AVD

• 5. Change AVD properties as needed, and then click Finish.


• Now you get a new AVD ready for launching your apps on it.
Emulators

• The Android Emulator simulates Android devices on your computer so that you can test
your application on a variety of devices and Android API levels without needing to have
each physical device.
• The emulator provides almost all of the capabilities of a real Android device. You can
simulate incoming phone calls and text messages, specify the location of the device,
simulate different network speeds, simulate rotation and other hardware sensors, access the
Google Play Store, and much more.
• The emulator comes with predefined configurations for various Android phone, tablet, Wear
OS, and Android TV devices.
• In short, An Android emulator is an Android Virtual Device (AVD) that represents a
specific Android device. You can use an Android emulator as a target platform to run and
test your Android applications on your PC. Using Android emulators is optional.

• To start the emulator:


• 1. Open the AVD Manager.
• 2. Double-click an AVD, or click Run

• The Android Emulator loads.


Dalvik Virtual Machine (DVM)

• The Dalvik Virtual Machine (DVM) is an android virtual machine optimized for mobile
devices. It optimizes the virtual machine for memory, battery life and performance.
• The Dex compiler converts the class files into the .dex file that run on the Dalvik VM.
Multiple class files are converted into one dex file.

• Fig.: The compiling and packaging process from the source file
Dalvik Virtual Machine (DVM)

• 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.
Difference between JVM and DVM

DVM (Dalvik Virtual Machine) JVM (Java Virtual Machine)

It is Register based which is designed to run on low


It is Stack based.
memory.

DVM uses its own byte code and runs “.Dex” file. From JVM uses java byte code and runs “.class” file having
Android 2.2 SDK Dalvik has got a Just in Time compiler JIT (Just In Time).

DVM has been designed so that a device can run


Single instance of JVM is shared with multiple
multiple instances of the VM efficiently. Applications
applications.
are given their own instance.

DVM supports Android operating system only. JVM supports multiple operating systems.

For DVM very few Re-tools are available. For JVM many Re-tools are available.

There is constant pool for every application. It has constant pool for every class.

Here the executable is APK. Here the executable is JAR.


Mobile Application Development

Unit- 2
Installation

• Java

1. Visit http://www.oracle.com/technetwork/java/javase/downloads/index.html
2. Install it.
• Android Studio

3. Visit http://developer.android.com/sdk/index.html
4. click the button Download Android Studio.
5. Accept terms, and click Download.
6. Run executable file of setup.
7. Follow the setup wizard to install Android Studio and any necessary SDK tools.
8. On some Windows systems, the launcher script does not find where Java is installed. If
you encounter this problem, you need to set an environment variable indicating the
correct location.
9. Select Start menu > Computer > System Properties > Advanced System Properties.
Then open Advanced tab > Environment Variables and add a new system variable
JAVA_HOME that points to your JDK folder, for example C:\Program Files\Java\
jdk1.7.0_45
• launched android-studio-ide-181.5056338-windows.exe to start the installation process. The
installer responded by presenting the Android Studio Setup dialog box shown in Figure 1.

• 1. Set up Android Studio


• Clicking Next will take you to the following panel, which provides the option to decline
installing an Android Virtual Device (AVD).
• chose to keep the default settings.

• After clicking Next, the Configuration Settings panel will be shown,


• where you will be asked to choose where to install Android Studio.
• clicking Next will open Choose Start Menu Folder panel.

• keep the default setting and click Install


• The following Installing panel will appear:

• When installation finished, the Installation Complete panel appeared.


• When installation finished, the Installation Complete panel appeared.
• After clicking Next, the installer presented the Completing Android Studio Setup panel.

• To complete the installation, leave Start Android Studio box checked and click Finish.
• The first time Android Studio runs, it presents a Complete Installation dialog box that offers the
option of importing settings from a previous installation.

• choose not to import settings (the default selection) and click OK, the following splash screen
will appear:
Running Android Studio

• You will observe the following Finding Available SDK Components message box.
Running Android Studio

• Android Studio will present the following Android Studio Setup Wizard dialog box:
• Click Next, and the wizard will invite you to select an installation type. Keep the default
standard setting.
• Then you can choose a user interface theme.
• You can choose whichever you want and click Next. Android Studio will next provide the
opportunity to verify settings.
• click Finish and Android Studio will begin the process of downloading SDK components.
Running Android Studio

• It can take several minutes for this part of the setup to finish.
• Finally, click Finish to complete the wizard. The Welcome to Android Studio dialog box
appear.

• This dialog box is used to start up a new Android Studio project, work with an existing project,
and more. It can be accessed by selecting Android Studio from the Windows Start menu, or the
equivalent on another platform.
Mobile Application Development

Unit- 3
ANDROID APPLICATION DIRECTORY
STRUCTURE

• some important files/folders, and their for the


easy understanding of the Android studio
work environment are shown in following
figure.
• AndroidManifest.xml:
• Every project in Android includes a manifest file, which is
AndroidManifest.xml, stored in the root directory of its project
hierarchy.

• The manifest file is an important part of our app because 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.
• 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.
• drawable:

• A Drawable folder contains resource type file (something that can be


drawn). Drawables may take a variety of file like Bitmap (PNG,
JPEG), Nine Patch, Vector (XML), Shape, Layers, States, Levels,
and Scale.

• layout:

• A 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.
• <?xml version="1.0" encoding="utf-8"?>

• <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

• android:layout_width="match_parent"

• android:layout_height="match_parent"

• android:orientation="vertical" >

• <TextView android:id="@+id/text"

• android:layout_width="wrap_content"

• android:layout_height="wrap_content"

• android:text="Hello, I am a TextView" />

• <Button android:id="@+id/button"

• android:layout_width="wrap_content"

• android:layout_height="wrap_content"

• android:text="Hello, I am a Button" />

• </LinearLayout>
• mipmap:

• Mipmap folder contains the Image Asset file that can be used in
Android Studio application. You can generate the icon types like
Launcher icons, Action bar and tab icons, and Notification icons.

• colors.xml:

• colors.xml file 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.
• Below is a sample colors.xml file:

• <?xml version="1.0" encoding="utf-8"?>


• <resources>
• <color name="colorPrimary">#3F51B5</color>
• <color name="colorPrimaryDark">#303F9F</color>
• </resources>
• strings.xml:

• The strings.xml file 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.

• Below is a sample strings.xml file:

• <resources>
• <string name="app_name"> Polytechnic</string>
• </resources>
• styles.xml:
• The styles.xml file contains resources of the theme style in the
Android application. This file is written in XML language. Below is a
sample styles.xml file:
• <resources>
• <!-- Base application theme. -->
• <style name="AppTheme"
parent="Theme.AppCompat.Light.DarkActionBar">
• <!-- Customize your theme here. -->
• <item
name="colorPrimary">@color/colorPrimary</item>
• <item
name="colorPrimaryDark">@color/colorPrimaryDark</item>
• </style>
• </resources>
• build.gradle(Module: app):

• This defines the module-specific build configurations. Here you can


add dependencies what you need in your Android application.
Components of Screen

• Application components are the essential building blocks of an


Android application. These components are loosely coupled by the
application manifest file AndroidManifest.xml that describes each
component of the application and how they interact.

• Interface elements include but are not limited to:


• Input Controls: checkboxes, radio buttons, dropdown lists, list
boxes, buttons, toggles, text fields, date field
• Navigational Components: breadcrumb, slider, search field,
pagination, slider, tags, icons
• Informational Components: tooltips, icons, progress bar,
notifications, message boxes, modal windows
• Containers: accordion
Fundamentals of UI Design
• Android introduces some new terminology for familiar programming
metaphors
• ❑ Views- Views are the basic User Interface class for visual interface
elements (commonly known as controls or widgets). All User
Interface controls, and the layout classes, are derived from Views.
• ❑ ViewGroups- View Groups are extensions of the View class that
can contain multiple child Views. By extending the ViewGroup class,
you can create compound controls that are made up of interconnected
child Views. The ViewGroup class is also extended to provide the
layout managers, such as LinearLayout, that help you compose User
Interfaces.
• ❑ Activities- Activities represent the window or screen being
displayed to the user. Activities are the Android equivalent of a Form.
To display a User Interface, you assign a View or layout to an
Activity. Android provides several common UI controls, widgets, and
layout managers.
Layouts
• It is a type of resource which gives definition on what is drawn on the
screen or how elements are placed on the device’s screen and stored
as XML files in the /res/layout resource directory for the application.
It can also be a type of View class to organize other controls.

• There are many types of layout. Some of which are listed below −

• Linear Layout

• Absolute Layout

• Table Layout

• Frame Layout

• Relative Layout
LINEAR LAYOUT
• Linear layout is further divided into horizontal and vertical layout. It
means it can arrange views in a single column or in a single row.
Here is the code of linear layout(vertical) that includes a text view.
• A layout that organizes its children into a single horizontal or vertical
row. It creates a scrollbar if the length of the window exceeds the
length of the screen
Linear Layout
• <?xml version=”1.0” encoding=”utf-8”?>

• <LinearLayout
xmlns:android=”http://schemas.android.com/apk/res/android”
android:layout_width=”fill_parent” android:layout_height=”fill_parent”
android:orientation=”vertical” >

• <TextView

• android:layout_width=”fill_parent” android:layout_height=”wrap_content”

• android:text=”@string/hello” />

• </LinearLayout>
ABSOLUTELAYOUT
• The AbsoluteLayout enables you to specify the exact location of its
children. It can be declared like this.
• <AbsoluteLayout
• android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
xmlns:android=”http://schemas.android.com/apk/res/android” >
• <Button
• android:layout_width=”188dp”
android:layout_height=”wrap_content” android:text=”Button”
android:layout_x=”126px” android:layout_y=”361px” />
• </AbsoluteLayout>
TABLELAYOUT

The TableLayout groups views into rows and columns. It can be


declared like this.

<TableLayout xmlns:android=”http://schemas.android.com/apk/res/android”
android:layout_height=”fill_parent” android:layout_width=”fill_parent” >
<TableRow>
<TextView android:text=”User Name:” android:width =”120dp” />
<EditText android:id=”@+id/txtUserName” android:width=”200dp” />
</TableRow> </TableLayout>
RELATIVELAYOUT
• RelativeLayout enforces to display elements in relations to each other. You
can specify that, for instance, one UI element can be said to be placed on
the left of another element, or on the bottom of another etc. Each UI
element can also be positioned according to the layout’s borders (e.g.
aligned to the right)
RELATIVELAYOUT
• It can be declared like this.

• <RelativeLayout
• android:id=”@+id/RLayout”
• android:layout_width=”fill_parent”
• android:layout_height=”fill_parent”
• xmlns:android=”http://schemas.android.com/apk/res/android” >
• </RelativeLayout>
FRAMELAYOUT
• The FrameLayout is a placeholder on screen that you can use to
display a single view. It can be declared like this.

• <?xml version=”1.0” encoding=”utf-8”?>


• <FrameLayout
• android:layout_width=”wrap_content”
• android:layout_height=”wrap_content”
• android:layout_alignLeft=”@+id/lblComments”
• android:layout_below=”@+id/lblComments”
• android:layout_centerHorizontal=”true” >
• <ImageView android:src = “@drawable/droid”
• android:layout_width=”wrap_content”
• android:layout_height=”wrap_content” />
• </FrameLayout>
OTHER ATTRIBUTES THAT ARE COMMON IN ALL VIEWS AND VIEWGROUPS
Sr.No View & description

1 layout_width
Specifies the width of the View or ViewGroup
2 layout_height
Specifies the height of the View or ViewGroup
3 layout_marginTop
Specifies extra space on the top side of the View or ViewGroup

4 layout_marginBottom
Specifies extra space on the bottom side of the View or ViewGroup

5 layout_marginLeft
Specifies extra space on the left side of the View or ViewGroup

6 layout_marginRight
Specifies extra space on the right side of the View or ViewGroup

7 layout_gravity
Specifies how child Views are positioned
8 layout_weight
Specifies how much of the extra space in the layout should be allocated to the View

You might also like