Mobile Application Development: Dr. Babasaheb Ambedkar Open University Ahmedabad
Mobile Application Development: Dr. Babasaheb Ambedkar Open University Ahmedabad
DEVELOPMENT
PGDCA 203
BLOCK 2:
ANDROID APPLICATION AND
USER INTERFACE DESIGN
Author
Er. Nishit Mathur
Language Editor
Prof. Jaipal Gaikwad
Acknowledgment
Every attempt has been made to trace the copyright holders of material reproduced
in this book. Should an infringement have occurred, we apologize for the same and
will be pleased to make necessary correction/amendment in future edition of this
book.
The content is developed by taking reference of online and print publications that
are mentioned in Bibliography. The content developed represents the breadth of
research excellence in this multidisciplinary academic field. Some of the
information, illustrations and examples are taken "as is" and as available in the
references mentioned in Bibliography for academic purpose and better
understanding by learner.'
ROLE OF SELF INSTRUCTIONAL MATERIAL IN DISTANCE LEARNING
UNIT 1
ANDROID APPLICATION DESIGN ESSENTIALS - II 03
UNIT 2
ANDROID USER INTERFACE DESIGN AND COMMON APIS 15
BLOCK 2: ANDROID APPLICATION AND
USER INTERFACE DESIGN
Block Introduction
Intents are asynchronous messages which permit application components to
request functionality from other android components. Intents allow you to interact
with components from the same applications additionally like components
contributed by other applications. The new Fragment API for android, introduced
in android 3.0, permits for easier dynamic user interfaces. API that is application
program interface may be a set of routines, protocols, and tools for building
software applications.
In this block, we will detail about the basic of Intent messages and usability
of application components. The block will focus on the study and concept of
running android 6.0 with API level 23 with permission requiring for access of
additional features. You will get an idea on application in Android with necessity
of Manifest.xml file.
In this block, you will make to learn and understand about new Fragment
API for android for easy dynamic user interfaces. The concept related to interface
elements in android app using view and ViewGroup objects will also be explained
to the students. The student will be demonstrated practically about animations.
Block Objective
After learning this block, you will be able to understand:
Concept of Layouts
1
Android Block Structure
Application and
User Interface Unit 1: Android Application Design Essentials - II
Design
Unit 2: Android Application Design Essentials - I
2
UNIT 1: ANDROID APPLICATION DESIGN
ESSENTIALS - II
Unit Structure
1.0 Learning Objectives
1.1 Introduction
1.8 Glossary
1.9 Assignment
1.10 Activities
1.1 Introduction
Your app's user interface is collectively that the user can see and collaborate
with. Android provides a variety of pre-built UI components such as structured
layout objects and UI controls that allow you to build the graphical user interface
3
Android for your app. Android also provides other UI modules for different interfaces such
Application and as dialogs, notifications, and menus.
User Interface
Design
A component will register itself via an intent filter for a selected action and
specific data. an intent filter specifies the kinds of intents to that an activity,
service, or broadcast receiver will respond to by declaring the capabilities of a
component.
If intent is sent to the android system, the android platform runs a receiver
determination. It uses the data included within the intent. If many components
have registered for the same intent filter, the user will decide that component
should be started.
Intent filter
You can register your android components via intent filters for certain
events. If a component doesn't define one, it will solely be referred to as by
explicit intents. This chapter offers an example for registering a component for
intent. The key for this registration is that your component registers for the correct
action, mime-type and specifies the correct meta-data.
4
To inform the system those implicit intents they will handle, activities, Android
services, and broadcast receivers will have one or more intent filters. each filter Application
Design
describes a capability of the component, a set of intents that the component is
Essentials - II
willing to receive. It, in effect, filters in intents of a desired kind, whereas filtering
out unwanted intents — however solely unwanted implicit intents (those that do
not name a target class). a certain intent is usually delivered to its target, no matter
what it contains; the filter isn't consulted. However an implicit intent is delivered
to a component as long as it will undergo one of the component's filters.
b. Data
c. Both of these
d. None of these
5
Android 1.3 Permissions
Application and
User Interface It's easy for an app to overwhelm a user with permission requests. If a user
Design
finds the app frustrating to use, or the user is worried regarding what the app could
be doing with the user's information, they will avoid using the app or uninstall it
entirely. Whenever you ask for permission, you force the user to form a decision.
You must minimize the amount of times you make these requests. If the user is
running android 6.0 (API level 23) or later, whenever the user tries some new app
feature that needs a permission, the app needs to interrupt the user's work with a
permission request. If the user is running an earlier version of golem, the user
needs to grant all of the app's permissions when installing the app; if the list is just
too long or appears inappropriate, the user could decide not to install your app at
all. For these reasons, you must minimize the amount of permissions your app
wants.
If the user is running android 6.0 (API level 23) or later, the user needs to
grant your app its permissions whereas they're running the app. If you confront the
user with a lot of requests for permissions promptly, you'll overwhelm the user
and cause them to quit your app. Instead, you should invite permissions as you
need them.
b. requestPermission()
c. broadcastReceiver()
d. None of these
It names the Java package for the application. The package name is a unique
identifier for the application.
It describes the components of the application — the activities, services,
broadcast receivers, and content providers that the application consists of. It
names the classes that implement every of the elements and publishes their
capabilities (for example, that Intent messages they will handle). These
declarations let the android system know what the components are and
under what conditions they will be launched.
It determines that processes can host application components.
It declares that permissions the application should have so as to access
protected parts of the API and interact with other applications.
It additionally declares the permissions that others are needed to have so as
to move with the application's components.
It lists the Instrumentation classes that provide profiling and other info
because the application is running. These declarations are present within the
manifest solely whereas the application is being developed and tested; they
are removed before the application is published.
It declares the minimum level of the android API that the application needs.
It lists the libraries that the application should be linked against.
AndroidManifest.xml could be a powerful go in the android platform that
enables you to describe the functionality and needs of your application to android.
7
Android However, working with it's not easy. Xamarin.Android helps to reduce this
Application and problem by permitting you to feature custom attributes to your classes, which can
User Interface
then be wont to automatically generate the manifest for you. Our goal is that 99 of
Design
our users should never need to manually modify AndroidManifest.xml.
AndroidManifest.xml is generated as a part of the build method, and also the
XML found inside Properties/AndroidManifest.xml is merged with XML that's
generated from custom attributes. The resulting merged AndroidManifest.xml
resides within the obj subdirectory; for example, it resides at
obj/Debug/android/AndroidManifest.xml for debug builds. The merging process
is trivial: it uses custom attributes within the code to generate XML elements, and
inserts those elements into AndroidManifest.xml.
8
Android
Application
Design
Essentials - II
All the elements that appear in manifest file are highlighted below. These
are the standard elements that are used in manifest files.
9
Android
Application and
User Interface
Design
a. java file
b. drivers
d. All of these
Android resource files are stored separately from the java class files within
the android project. Most common resource types are stored in XML. You’ll
additionally store raw data files and graphics as resources. Resources are
organized in a very strict directory hierarchy within the android project. All
resources should be stored under the /res project directory in specially named
subdirectories that has to be lowercase.
Application resources are created and stored within the android project files
under the /res directory. Employing a well-defined however flexible directory
structure, resources are organized, defined, and compiled with the appliance
package. Application resources are not shared with the rest of the android system.
Layout files
Resource sorts are defined with special XML tags and organized into
specially named project directories. Some /res subdirectories, like the /drawable,
11
Android /layout, and /values directories, are created by default once a new android project
Application and is formed, however others should be added by the developer once required.
User Interface
Design Resource files stored within /res subdirectories must abide by the following rules:
When resources are compiled, their name dictates their variable name. For
example,a graphics file saved within the /drawable directory as mypic.jpg is
referenced as @drawable/mypic. It’s necessary to name resource names
intelligently and be aware of character limitations that are stricter than file system
names. Consult the android documentation for specific project directory naming
conventions.
All application resources are keep within the /res project directory structure
and are compiled into the project at build time. Application resources may be used
programmatically. They’ll even be referenced in different application resources.
Application resources may be accessed programmatically using the generated
class file called R.java. To reference a resource from within your Activity class,
you must retrieve the application’s Resources object using the getResources()
method then build the appropriate method call, supported the kind of resource you
want to retrieve.
b. Layout folder
c. Res Folder of XML file
d. None of these
12
Android
1.6 Let Us Sum Up Application
Design
In this unit we have learnt that Intents are asynchronous messages which
Essentials - II
permit application components to request functionality from other android
components that allow interacting with components from similar applications with
components that are contributed by other applications.
If user is running android 6.0 or later, whenever the user tries some new app
feature that needs permission, the app needs to interrupt the user's work with a
permission request.
Answers: (1 -b)
Answers: (1 -c)
1.8 Glossary
1. Activity - An application screen that supports Java code from Activity class.
13
Android 2. Application - In Android application, there are activities, services, listeners
Application and and intent receivers.
User Interface
Design 3. Intent - Message object which uses to communicate with certain
applications/activities asynchronously.
1.9 Assignment
Explain intent and intent filters with the help of an example.
1.10 Activities
Study android manifest file of your project.
14
UNIT 2: ANDROID USER INTERFACE
DESIGN AND COMMON APIS
Unit Structure
2.0 Learning Objectives
2.1 Introduction
2.8 Glossary
2.9 Assignment
2.10 Activities
2.1 Introduction
The new Fragment API for android, introduced in android 3.0, permits for
easier dynamic user interfaces. API that is application program interface may be a
set of routines, protocols, and tools for building software applications. The API
specifies however software components should interact and apis are used once
15
Android programming graphical program (GUI) components. A good API makes it easier
Application and to develop a program by providing all the building blocks. A programmer then
User Interface
puts the blocks together.
Design
To declare your layout, you can instantiate View objects in code and start
building a tree, but the easiest and the most effective way to define your layout is
by using an XML file. XML offers a human-readable structure for the layout,
similar to HTML. The name of an XML element for a view is respective to the
Android class it represents. So a <TextView> element creates a TextView widget
in your UI, and a <LinearLayout> element creates a LinearLayout view group.
16
Check your progress 1 Android User
Interface
1. What is view group? Design and
Common APIS
a. class
b. It is a collection of views
c. object
d. None of these
2. What are the attributes of <TextView>?
a. android:id
b. android:editable
c. android:fontFamily
d. All of these
Instantiate layout elements at runtime. Your application will create read and
ViewGroup objects (and manipulate their properties) programmatically.
The android framework provides you the flexibility to use either or each of
those methods for declaring and managing your application's UI. For example,
you'll declare your application's default layouts in XML, including the screen
elements which will seem in them and their properties. You’ll then add code in
your application that would modify the state of the screen objects, including those
declared in XML, at run time.
The advantage to declaring your UI in XML is that it allows you to better
separate the presentation of your application from the code that controls its
behavior. Your UI descriptions are external to your application code, which
implies that you simply will modify or adapt it while not having to modify your
source code and recompile. For example, you'll produce XML layouts for
17
Android different screen orientations, totally different device screen sizes, and totally
Application and different languages. Additionally, declaring the layout in XML makes it easier to
User Interface
visualize the structure of your UI, therefore it's easier to debug problems. As such,
Design
this document focuses on teaching you how to declare your layout in XML. If you
are interested in instantiating view objects at runtime, refer to the ViewGroup and
view class references.
XML layout attributes named layout_something define layout parameters
for the view that are acceptable for the ViewGroup in which it resides.
18
In addition, many convenience strategies are offered to avoid unnecessary Android User
computations, specifically getRight() and getBottom(). These strategies come the Interface
coordinates of the correct and bottom edges of the rectangle representing the view. Design and
Common APIS
for instance, calling getRight() is similar to the following computation: getLeft() +
getWidth().
Each subclass of the ViewGroup class provides a unique way to show the
views you nest within it. Below are a number of the a lot of common layout types
that are built into the android platform.
b. In Resource folder
c. Not defined clearly
d. None of these
2. What is linear layout?
19
Android 2.4 Drawing and Working with Animation
Application and
User Interface It is found that in Android, the framework provides dual animation systems:
Design
property animation
view animation
The above two animation systems are practical options, whereas the
property animation system is preferred method to apply as it is flexible and offers
more features. Additionally, these two systems will allow drawable animation that
can be easily available to load drawable resources and will show in single frame
one after another.
Animation
Animation is the base of Android application as users like things which tend
to move here and there on the screen. Animations appear as advance way which
helps in improving user expertise for particular application that will help in
standing out. The best animations are the ones that users don’t happen to see as it
looks natural. Android provides the following three API’s for:
View Animation:
It serves as genuine API which Android gives. Such type of animations is
fixed to particular View and will able to do simple transformations of contents
regarding particular View. Being simple and ease, such API tends to be of use for
things which can be an alpha animation, rotations and further.
Property Animation:
This type of animation is introduced in Android which allows an application
to animate with all its features. It is of used when an change in property of an
object appears, as if particular object is not visible on screen.
Drawable Animation:
It is a special Drawable resource which on application results in simple
animation effect along with its layouts.
20
Android User
Check your progress 3 Interface
Design and
1. To change the property of an object we use_________.
Common APIS
a. View Animaton
b. Drawable Animation
c. Property Animation
d. All of these
2D Graphics
Drawable Resources are customary as well as elevated mechanism in
Android applications. As with external expedients, Drawable Resources are
affirmative – they’re described in XML files. This access authorizes for a filter
estrangement of code from reserves. This can advance execution as well as
extension since it is not essential to alter code to update or convert the graphics in
an Android application.
Furthermore, while Drawable Resources are advantageous for ample
elementary as well as common graphic conditions, however the default the power
as well as control of the Canvas API.
22
The Canvas API utilizes the painter’s archetypal to illustrate 2D graphics. Android User
Actions are conducted in successive levels on foremost of each other. Each Interface
behavior will overlay numerous domain of the basic bitmap. When the domain Design and
Common APIS
interlaces a subsequently painted domain the fresh paint will fractionally or
entirely darken the old. This is the equivalent approach abundant other drawing
APIs comparable as System.Drawing along with iOS’s Core Graphics function.
a. Canvas
b. Drawable resources
c. Both of these
d. None of these
2. Why canvas is better than drawable resource for creating graphics?
23
Android It is noted that animations are great way to improve user experience of an
Application and application which help it stand out. The best animations are the ones that users
User Interface
don’t notice because they feel natural.
Design
Answers: (1 –c)
2.8 Glossary
1. Intent - Message object which uses to communicate with certain
applications/activities asynchronously.
2. Intent Filter - It is an object filter application which is present in manifest
file which shows system with its types of components.
3. Animation - Motion of objects created with software that allows moving an
image in motion graphics.
2.9 Assignment
Write differences among canvas and drawable resources for creating
graphics.
24
2.10 Activities Android User
Interface
Design UI of a registration system. Design and
Common APIS
25
Android Block Summary
Application and
User Interface In this block, you have learnt and understand about the basic of
Design
asynchronous messages and use of permissions for developing Android features.
The block gives an idea on use of Intent in interacting with components along
with extra components. You have been well explained on the various criteria’s
and rules to be followed for permission of rights.
The block detailed about the basic of visual structure for a program along
with usability of AndroidManifest.xml file. The concept related to User Interface
with respect to activity or applications are also explained to you. You will be
demonstrated practically about 2D and 3D animations in Android.
26
Block Assignment
Short Answer Questions
1. How animation can be applied in android?
2. What is the difference between intent and intent filters
27
Android Enrolment No.
Application and
User Interface 1. How many hours did you need for studying the units?
Design
Unit No 1 2 3 4
Nos of Hrs
2. Please give your reactions to the following items based on your reading of
the block:
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
………………………………………………………………………………………………
28
Education is something
which ought to be
brought within
the reach of every one.
- Dr. B. R. Ambedkar