(Affiliated to Saurashtra University & Gujarat Technological University)
Mobile Application Development in
Android using Java
MSCIT SEM-2
Unit – 1 Introduction to Android & Android Application Design
◼ The Open Handset Alliance
◼ The Android Platform, Android SDK
◼ Building a sample Android application
◼ Anatomy of an Android applications
◼ Android terminologies
◼ Application Context, Activities, Services, Intents
◼ Receiving and Broadcasting Intents
◼ Android Manifest File and its common settings
◼ Using Intent Filter, Permissions
◼ Managing Application resources in a hierarchy Working
with different types of resources
1
(Affiliated to Saurashtra University & Gujarat Technological University)
Handset Manufacturers
➢ Before Android, mobile developers faced many problem when it
came to writing application.
➢ Building the better application, the unique application, the
competing application, the hybrid application and incorporating
many common tasks such as messaging and calling in a familiar
way were often unworkable goals.
First Generation Mobile
➢ These early phones were some problem, but they did something
important – They changed the way about communication.
➢ As mobile phone prices dropped, batteries improved, and
reception areas grew, more and more people began carrying these
handy devices.
WAP(Wireless Application Protocol)
➢ Wireless Application Protocol (WAP) is a technical standard for
accessing information over a mobile wireless network
➢ A WAP browser is a web browser for mobile devices such as
mobile phones that use the protocol.
➢ User filled out a simple order form with his phone number and his
handset model.
➢ It was up to the content provider to deliver an image or audio file
compatible with the given phone.
➢ Payment and verification were handled through various premium
priced delivery mechanisms such as Short Message Service
(SMS), Enhanced Messaging Service (EMS), and Multimedia
Messaging Service (MMS).
Different Platforms
➢ A variety of different platforms emerged—and developers are
still actively creating applications for them.
o Some smartphone devices ran Palm OS (now
Garnet OS) and RIM BlackBerry OS.
2
(Affiliated to Saurashtra University & Gujarat Technological University)
o Sun Microsystems took its popular Java platform and
J2ME emerged (now known as Java Micro Edition
[Java ME]).
o Chipset maker Qualcomm developed and licensed its
Binary Runtime Environment for Wireless (BREW).
o Other plat- forms, such as Symbian OS, were
developed by handset manufacturers such as
Nokia,Sony Ericsson, Motorola, and Samsung.
o The Apple iPhone OS (OS X iPhone) joined the ranks in
2008.
The Open Handset Alliance.(જોડાણ)
◼ The Open Handset Alliance (OHA) is a consortium of 84 firms to
develop open standards for mobile devices.
◼ Members include HTC, Sony, Dell, Intel, Motorola, Qualcomm, Texas
Instruments, Google, Samsung Electronics, LG Electronics, T-Mobile,
Sprint Corporation (now merged with T-Mobile US), Nvidia, and Wind
River Systems.
◼ The Open Handset Alliance (OHA) was formed in November
2007.
◼ The OHA is a business alliance comprised(સમાવેશ) of many of the
largest and most successful mobile companies on the planet.
◼ Its members include chip makers, handset manufacturers, software
developers, and service providers.
◼ The entire mobile supply chain is well represented.
◼ Google was found this alliance.
◼ Head quarter at Mountain View, California, United States .
◼ The Open Handset Alliance is a group of mobile and technology leaders
who share this vision for changing the mobile experience for consumers.
◼ Andy Rubin has been credited as the father of the Android
platform.
◼ His company, Android Inc., was acquired (Purchased) by Google
in 2005.
◼ Working together, OHA members, including Google, began
developing a non-proprietary(માલિકી) open standard platform based
3
(Affiliated to Saurashtra University & Gujarat Technological University)
upon technology developed at Android Inc.
◼ that would aim to alleviate(improve) the main problems comes the
mobile community.
◼ The result is the Android project. To this day, most android
platform development is completed by Rubin’s team at Google,
where he acts as VP of Engineering and manages the Android
platform roadmap.
◼ Google hosts the Android open source project and provides online
Android documentation, tools, forums, and the Software
Development Kit (SDK) for developers. All major Android news
originates at Google.
Sr.no Questions Answer
1 OHA full form is Open Handset Alliance
2 OHA formed in November 2007
3 WAP full form is_ Wireless Application Protocol
The Android Platform
◼ The Android Platform was launched in 2007 by the Open Handset
Alliance(Jodan), an alliance of famous companies that includes Google,
HTC, Motorola and others.
◼ Although most of the applications that run on the Android Platform are
written in Java, there is no Java Virtual Machine.
◼ Instead, the Java classes are first compiled into what are known as Dalvik
Executable and run on the Dalvik Virtual Machine. Pre-commercial
release versions Alpha -> Release November 2007 Beta -> Release Nov
5, 2007. Latest version of android with logo.
4
(Affiliated to Saurashtra University & Gujarat Technological University)
Features of android:-
◼ Free and Open Source
◼ Familiar and Inexpensive Development Tools
◼ Freely Available Software Development Kit
◼ Familiar Language, Familiar Development Environments
o Windows XP (32-bit) or Vista (32-bit or 64-bit)
o Mac OS X 10.5.8 or later (x86 only)
o Linux (tested on Linux Ubuntu 8.04 LTS, Hardy Heron)
◼A “Free Market” for Applications
• Android developers can distribute their applications to users in a variety of
ways:
Android SDK
◼ The Android Software development kit (SDK).
◼ includes a comprehensive set of development tools.
◼ These include a debugger, libraries, a handset emulator based on Quick
Emulator, documentation, sample code, and tutorials
◼ It use java programming
◼ The officially supported integrated development environment (IDE) is
Eclipse using the Android Development Tools (ADT) Plugin.
◼ But now Android Studio is the official IDE;
◼ Note : You must install java 1.6 or latter in order to work on android
5
(Affiliated to Saurashtra University & Gujarat Technological University)
◼ What is Android?
The Android operating system
✓ Android is a mobile operating system based on a modified version of
the Linux kernel and other open-source software, designed primarily
for touchscreen mobile devices such as smartphones and tablets.
✓ Android is an operating system based on the Linux kernel.
✓ The first commercial Android device the HTC Dream, being launched
in September 2008.
✓ Over 70 percent of smartphones based on Android
✓ Android written in c. c++, java , Kotlin and many other.
✓ It available in 100 + languages.
✓ Latest version of android is android 14, released on 4th October-23
✓ The project responsible for developing the Android system is called
the Android Open Source Project (AOSP) and is primarily lead by
Google.
✓ The Android system supports background processing, provides a rich
user interface library, supports 2-D and 3-D graphics using the
OpenGL-ES (Open Graphics Library for Embedded Systems (short
OpenGL) standard and grants access to the file system as well as an
embedded SQLite database.
✓ An Android application typically consists of different visual and non
visual components and can reuse components of other applications.
6
(Affiliated to Saurashtra University & Gujarat Technological University)
Anatomy(રચના) of an Android applications
◼ Android application is developed by one or more components that
work together, these components are activities.
◼ Activity is a single and independent module that is correlated to the
application's single screen and its functionalities
◼ There are four main building block to android application likes
• Activity.
• Intent receiver(intent)
• Services
• Content provider.
1) Intent :-
➔ Intent is messaging object used to request any action from another
application component.
➔ Intents facilitate communication between different components in
many ways.
➔ Example of intent are gallery, browser, contact many other tab in our
mobile.
2) Services:-
➔ A Service is an application component that can perform long-running
operations in the background. It does not provide a user interface.
3) Content provider:-
➔ Content providers are the standard interface that connects data in one
process with code running in another process.
➔ Implementing a content provider has many advantages.
Some of other anatomy (framer or body of android are as follow.
◼ Src : Java or kotlin source code files will be available here.\
7
(Affiliated to Saurashtra University & Gujarat Technological University)
◼ Res : res used to store the values for resources that are used in many
android project to include color , style andy many other.
• it is folder available in android studio.
◼ /res/values : Used to define strings, colors, dimensions, styles, static
arrays etc. Ex. String are defined in the res/values/string.xml file.
◼ /res/layout : This folder contains the layouts to be used in the application.
◼ /res/menu : This folder contains menu resources to be used in the
application
◼ /res/drawable : 1) Drawable resource is general concept for a graphics
that can be drawn to the screen.
2) Drawable folders are resource directories in the application that
provides differrent bitmap drawables for medium, high and extra high
solidity screens.
Explain Android terminologies
1) apk file :
➔ Android application package file.
➔ Android package kit file.
➔ it is file format for application used on android os
2) dex file :
➔ Delvik Executable File that all application must have.
➔ It Compiled Android application code file.
➔ .dex files can be created by automatically translating compiled
applications written in the java programming language.
8
(Affiliated to Saurashtra University & Gujarat Technological University)
3) Action :
An action is a string value assigned to Intent.
4) Activity :
➔ It is specifies combination of xml file and java files, Kotlin file.
➔ It combine coding and design
5) Adb :
➔ Android Debug Bridge, a command line debugging application
includes with the SDK.
➔ It is versatile command line tool that communicate with device. Such
as installing and debugging app.
6) Canvas : Canvas is the simplest, easiest way to draw 2D objects on
the screen.
7) Content Provider : A content provider is built in the ContentProvider
class. It is used to store and retrieve data such as contact, images,
videos ,music other media.
8) Dalvik:
➔ It is discontinue process virtual machine in android os..
➔ The Android Platform’s virtual machine.
➔ The Dalvik VM is an interpreter only VM that executes files in the
Dalvik Executable (.dex) format.
➔ It not used in newer version of android.
9) DDMS : Dalvik Debug Monitor Service, a GUI debugging application
included with the SDK.
10) Dialog : dialog is small window that prompts the user to make
decision or enter additional Information. It is simple button like
checkbox radio button.
11) Drawable : this resources is general concept for graphics that can be
drawn to the screen.
12) Layout Resources : An XML file that describes that layout of an
Activity screen
13) Manifest File : An XML file that each application must define, to
describe the app’s package name, version, component etc.
14) XML:in android, xml is used for designing the application’s user
interface(UI)like creating layout ,view ,buttons ,text fields etc.
15) Emulator:- it is android virtual device , here we can run and test
our project .
9
(Affiliated to Saurashtra University & Gujarat Technological University)
What is Application Context?
• Context is the interface that contain fully detail information about
application or your project.
• Context is allow to access string , themes, color and many other.
• It used to application-level operations such as launching activities,
broad casting and receiving intents.
• It is first step or first page of our project.
What is Activity?:-
◼ If you have worked with C, C++ or Java programming language then you
must have seen that your program starts from main() function.
◼ Very similar way, Android system start its program with Activity.
◼ It is specifies combination of xml file and java files, Kotlin file.
◼ It combine coding and design
◼ The xml file provide the design of the screen and java or Kotlin file deal
with coding
◼ Activity consist of two things like front end and back end .
◼ Activity life cycle diagram(Explain activity lifecycle in detail):
10
(Affiliated to Saurashtra University & Gujarat Technological University)
◼ Main components of lifecycle:-
(i) onCreate():- This is the first steps. It is called when the activity
is first created.
(ii) onStart():- This method is called when the activity becomes
visible to the user.
(iii) onResume():This method is called when the user starts interacting
with the application.
(iv) onPause() it called when activity is not visible to the user.
(v) onStop() This method is called when the activity is no longer
visible.
11
(Affiliated to Saurashtra University & Gujarat Technological University)
(vi) onDestroy() This method is called before the activity is destroyed
by the system.
(vii) onRestart() This method is called when the activity restarts after
stopping it.
◼ Explain Service in detail.
➔ A service is a component that runs in the background to perform long-
running operations without needing to interact with the user and it
works even if application is destroyed.
➔ For example, a service might play music in background while user in
a different application, or it might fetch data over network without
blocking user interface with an activity.
➔ A service can necessary take two states likes started and bound
1) Started:-
◼ A service is started when an application component, such as an activity,
starts it by calling startService().used for only for single activity.
◼ Once started, a service can run in the background .
2) Bound:-
• A service is bound when an application component binds to it by calling
bindService().used for two or more activity
• A bound service offers a client-server interface that allows components to
interact with the server, send requests, get results.
12
(Affiliated to Saurashtra University & Gujarat Technological University)
◼ The diagram on left show the lifecycle when the services is created with
startservice().it used only for one activity .
◼ The diagram on right show the lifecycle when the services is created with
bindservice().it is used more then one activity.
➔ Explain Intents:-
◼ an intent is to perform an action on the screen.
◼ Intent are used to start activity.
◼ Start a services(open email , web browser ,& calling).
◼ It also used for broadcast messaging.
◼ Pass data in same application or different application.
◼ There are two intents available in android as Implicit Intents and Explicit
Intents.
Types of Intents:-
13
(Affiliated to Saurashtra University & Gujarat Technological University)
1) Explicit Intent:-
◼ Communication between two activities inside the same application.
2) Implicit Intents:-
◼ Communication between two activities of different application.
Explain Receiving and Broadcasting Intents:-
◼ Broadcast in android is the system events.
◼ It can occur when the device is start or msg is receive on device.
◼ It also occur when incoming call are received or device are goes to
airplane mode.
◼ It is used to response the system event.
◼ Thera are two type of broadcast receiver like 1) Static Broadcast 2)
Dynamic broadcast receiver.
14
(Affiliated to Saurashtra University & Gujarat Technological University)
1) Static broadcast receiver:-
◼ These type of receiver are declare in the manifest file and works even If
the app is closed.
2)Dynamic broadcast receiver:-
◼ These type of receiver are works only if the app is running or minimize.
◼ Some the important intent generate by system are as follow
1) android.intent.action.BATTERY_CHANGED:-
◼ it indicate that changed the battery.
2) android.intent.action.BATTERY_Low:-
◼ Indicates low battery condition on the device.
3) android.intent.action.BATTERY_OKAY:-
◼ Indicates the battery is now okay after being low.
4) android.intent.action.BOOT_COMPLETED:-
◼ This is broadcast once, after the system has finished booting.
5) android.intent.action.BUG_REPORT :-
◼ Show activity for reporting a bug.
6) android.intent.action.REBOOT:-
◼ Have the device reboot.
15
(Affiliated to Saurashtra University & Gujarat Technological University)
Explain Android Manifest File and its common settings:-
◼ The Android Manifest is an XML file.
◼ It is simple text file that provide all the information about app.
◼ When we can create any app , default manifest file is created
automatically.
◼ it contains important metadata about the Android app.
◼ This includes the package name, activity names, main activity, Android
version support, hardware features support, permissions, and other
configurations.
◼ The Android manifest file helps to declare the permissions.
◼ It also declares the android api that the application is going to use.
The elements used in the xml file are described below.(common setting
in manifest file)
➔ <manifest>:-
◼ manifest is the root element of the AndroidManifest.xml file.
16
(Affiliated to Saurashtra University & Gujarat Technological University)
◼ It is define components of app.
➔ <application>:-
◼ application is the sub element of the manifest.
◼ It includes the namespace declaration.
◼ This element contains many sub elements.
◼ It contain app basic icon , icon label and themes for any app.
◼ The commonly used attributes are of this element are icon, label, theme
etc.
o android:icon represents the icon for all the android application
components.
o android:label works as the default label for all the application
components.
o android:theme represents a common theme for all the android
activities.
➔ Activity:- activity is the sub element of application.
◼ It communication of main codding file like java or Kotlin.
◼ If activity can not declare then app is never run.
17
(Affiliated to Saurashtra University & Gujarat Technological University)
What is Resources in android ? explain in detail.
Or
Explain Managing Application resources in a hierarchy and Working
with different types of resources:-
◼ There are many more items which we can use to build a good Android
application.
◼ Resources are the additional files and static content that our 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.
➔ anim/:- XML files that define property animations. They are saved in
res/anim/ folder.
➔ color/:- XML files that define a state list of colors. They are saved in
res/color/ .
18
(Affiliated to Saurashtra University & Gujarat Technological University)
➔ Drawable/ :- Image files like .png, .jpg, .gif or XML files that are
compiled saved in res/drawable/
➔ Layout/ :- XML files that define a user interface layout. They are
PART-2 Android User Interface Design
◼ User Interface Screen elements
➔Button, EditText, TextView, DatePicker, TimePicker,
ProgressBar, ListView, GridView, RadioGroup,
ImageButton, Fragement
◼ Designing User Interfaces with Layouts
➔ Relative Layout, Linear Layout, Table Layout etc
◼ Dialogs
◼ Drawing and Working with Animation
◼ Twined Animation
Q. Explain Front end and back end in android.
Front End:-
◼ It is all about what a user can see.
19
(Affiliated to Saurashtra University & Gujarat Technological University)
◼ It’s may be button, images, layout and input field and many more.
◼ To design these component in android we need XML and Android
programming (Kotlin or Java)
◼ It is also called UI.
Back End:-
◼ Back end of anything is not visible to general user or administrator.
◼ It can be piece of code or program running on the server machine to
serve the user need.
◼ Date base is also a part of backend (like SQLite).
◼ It is also called Uact
Q. Explain User interface overview.(UI):-
➔ The role of the UI is to display the application data on the screen and
also to serve as the primary point of user interaction.
➔ Whenever the data changes, either due to user interaction (like
pressing a button) or external input (like a network response), the UI
should update to reflect those changes.
◼ UI screen elements:
➔ TextView
➔ EditText
➔ AutoCompleteTextView
➔ Button ImageButton
➔ ToggleButton
➔ RadioButton
➔ RadioGroup
➔ ProgressDialog
➔ Spinner
➔ Time Picker
➔ Date Picker
➔ ListView
➔ GridView
➔ Fragment.
20
(Affiliated to Saurashtra University & Gujarat Technological University)
Note:- android Studio Download and install full step by step video link please
watch this video carefully and then install android studio.
Link:- https://www.youtube.com/watch?v=FIKNriGpncU&t=253s\
Q. Explain View in android.
Ans :-
◼ There are four basic views in android.
➔ Button
➔ TextView.
➔ ImageView.
➔ EditText.
1) Text view :-
◼ TextView is a user interface control that is used to set and display the text
to the user based on our requirements.
21
(Affiliated to Saurashtra University & Gujarat Technological University)
◼ The TextView control will act as like label control and it won't allow
users to edit the text.
◼ A TextView is a complete text editor, however the basic class is
configured to not allow editing.
◼ Label means textview in android.
Textview attributes
◼ android: id :- This is the ID which uniquely identifies the control .
◼ android:capitalize:- If set, specifies that this TextView has a textual
input method and should automatically capitalize what the user types.
◼ android:fontFamily:- Font family (named by string) for the text.
◼ android:maxHeight:- deifne height of this view
◼ android:maxwidth:- deifne width of this view
◼ android:text:- text to be display is this text view.
◼ Android text size:- define the size of text to be display in text view.
◼ Tools:layout_editor_absoluteX:- define position in x axis .
◼ Tools:layout_editor_absolutey:- define position in y axis la
2) Edit text:-
◼ EditText is a predefined subclass of TextView.
22
(Affiliated to Saurashtra University & Gujarat Technological University)
◼ We use EditText in our applications in order to provide an input or
text field specially in forms.
◼ EditText (or PlainText) is used in the app whenever you need input
from the user side and proceed with its text (or value) in your app.
◼ EditText (or PlainText) is not only used to get plain text in your
application, but even you can use it to get values such as email,
number, password, etc.
Attributes of edittext:-
◼ android:text:- Used to set the text of the EditText
◼ android:textSize:- Used to set size of the text.
◼ android:textColor:- Used to set color of the text.
◼ android:textStyle:- Used to set style of the text. For example, bold,
italic, bolditalic, etc.
3) Button view or Button:-
23
(Affiliated to Saurashtra University & Gujarat Technological University)
◼ In Android applications, a Button is a user interface that is used to
perform some action when clicked or tapped.
◼ Android Button represents a push-button.
◼ Button is subclass of TextView class and CompoundButton is the
subclass of Button class.
◼ There are different types of buttons in android such as RadioButton,
ToggleButton, CompoundButton etc.
ATTRIBUTE AND DESCRIPTION
➔ android:id:-
◼ Used to specify the id of the view.
➔ android:text:-
◼ Used to the display text of the button.
➔ android:textColor:-
◼ Used to the display color of the text.
➔ android:textSize:-
◼ Used to the display size of the text.
➔ android:background:-
◼ Used to set the background of the view.
➔ android:textStyle:-
◼ Used to the display style of the text like Bold, Italic, etc.
4) IMAGE VIEW:-
24
(Affiliated to Saurashtra University & Gujarat Technological University)
◼ ImageView class is used to display any kind of image resource in the
android application either it can be android. graphics. Bitmap or android.
Graphics.
◼ ImageView is also used to control the size and movement of an image.
ATTRIBUTE AND DESCRIPTION
➔ android:id:-
◼ To uniquely identify an image view.
➔ android:src/app:srcCompat:-
◼ To add the file path of the inserted image.
➔ android:background:-
◼ To provide a background color to the inserted image.
➔ android:layout_width:-
◼ To set the width of the image.
➔ android:layout_height:-
◼ To set the height of the image.
Q- EXPLAIN RADIO BUTTON.
◼ RadioButton is a two states button which is either checked or
unchecked.
◼ If a single radio button is unchecked, we can click it to make checked
radio button.
◼ Once a radio button is checked, it cannot be marked as unchecked by
user.
25
(Affiliated to Saurashtra University & Gujarat Technological University)
◼ RadioButton is generally used with RadioGroup.
◼ RadioGroup contains several radio buttons, marking one radio button as
checked makes all other radio buttons as unchecked.
ATTRIBUTE AND DESCRIPTION
➔ android:id:- It is used to uniquely identify the control.
➔ android:checked:- It is used to specify the current state of radio
button
➔ android:gravity:- It is used to specify how to align the text like left,
right, center, top, etc.
➔ android:text:- It is used to set the text for the radio button.
➔ android:textColor:- It is used to change the color of text.
➔ android:textSize:- It is used to specify the size of the text.
➔ android:textStyle:- It is used to change the style (bold, italic,
bolditalic) of text.
➔ android:background:- It is used to set the background color for radio
button control.
Q- EXPLAIN CHECKBOX
◼ A CheckBox is a special kind of button in Android which has two states
either checked or unchecked.
◼ There are many other uses of the CheckBox like offering a list of
options to the user to choose from and the options are mutually
exclusive i.e., the user can select more than one option.
26
(Affiliated to Saurashtra University & Gujarat Technological University)
ATTRIBUTE AND DESCRIPTION
➔ android:id:- It is used to uniquely identify the control.
➔ android:checked:- To set the default state of a CheckBox as
checked or unchechek
➔ android:background: To set the background color of a CheckBox
➔ android:text:- Used to store a text inside the CheckBox
➔ android:fontFamily:- To set the font of the text of the CheckBox
➔ android:textSize:- To set the CheckBox text size
➔ android:layout_width:- To set the CheckBox width.
➔ android:layout_height:- To set the CheckBox height
Q- EXPLAIN Date Picker.
◼ Android DatePicker is a widget to select date.
◼ It allows you to select date by day, month and year.
27
(Affiliated to Saurashtra University & Gujarat Technological University)
Method and description.
➔ getDayOfMonth()
This method gets the selected day of month
➔ getMonth()
This method gets the selected month
➔ getYear()
This method gets the selected year
➔ setMaxDate(long maxDate)
This method sets the maximal date supported by this DatePicker in
milliseconds since January 1, 1970 00:00:00 in getDefault() time zone
➔ setMinDate(long minDate)
This method sets the minimal date supported by this NumberPicker in
milliseconds since January 1, 1970 00:00:00 in getDefault() time zone
➔ getCalendarView()
This method returns calendar view
➔ getFirstDayOfWeek()
This Method returns first day of the week
Q- EXPLAIN Time Picker.
◼ Time picker is a graphical user interface.
◼ It allows the user to select time from a time range.
◼ Android TimePicker widget is used to select date
◼ It allows you to select time by hour and minute. You cannot select time
by seconds.
◼ TimePicker Dialog is used in many applications where we have to book
appointments based on a specific time
28
(Affiliated to Saurashtra University & Gujarat Technological University)
Method and description.
◼ is24HourView()
➔ This method returns true if this is in 24 hour view else false
◼ isEnabled()
➔ This method returns the enabled status for this view
◼ setCurrentHour(Integer currentHour)
➔ This method sets the current hour
◼ setCurrentMinute(Integer currentMinute)
➔ This method sets the current minute
◼ setIs24HourView(Boolean is24HourView)
➔ This method set whether in 24 hour or AM/PM mode
Q- EXPLAIN Image button.
◼ Image button is button that display image on button.
◼ Displays a button with an image (instead of text) that can be pressed or clicked
by the user.
◼ By default, an ImageButton looks like a regular Button, with the standard
button background that changes color during different button states.
◼ It display normal button with custom images
29
(Affiliated to Saurashtra University & Gujarat Technological University)
ATTRIBUTE AND DESCRIPTION
➔ android:cropToPadding
◼ If true, the image will be cropped to fit within its padding.
➔ android:src
◼ This sets a drawable as the content of this ImageView.
➔ android:background
◼ This is a drawable to use as the background.
➔ android:contentDescription
◼ This defines text that briefly describes content of the view.
➔ android:id
◼ This supplies an identifier name for this view
Q- Explain progress bar.
◼ ProgressBars are used as loading indicators in android applications.
◼ These are generally used when the application is loading the data from
the server or database.
◼ There are different types of progress bars used within the android
application as loading indicators
◼ We can display the android progress bar dialog box to display the
status of work being done e.g. downloading file, analyzing status of work
etc.
◼ The ProgressDialog class provides methods to work on progress bar like
setProgress(), setMessage(), setProgressStyle(), setMax(), show() etc.
The progress range of Progress Dialog is 0 to 10000.
ATTRIBUTE AND DESCRIPTION
◼ id: id is an attribute used to uniquely identify a Progress bar.
◼ max: max is an attribute used in android to define maximum value of the
progress can take. It must be an integer value like 100, 200 etc.
◼ progress: progress is an attribute used in android to define the default
progress value between 0 and max. It must be an integer value.
30
(Affiliated to Saurashtra University & Gujarat Technological University)
◼ background: background attribute is used to set the background of a
Progress bar. We can set a color or a drawable in the background of a
Progress bar.
Q- EXPLAIN List view.
◼ ListView is widely used in android applications.
◼ A list is any information display or organized in logical form.
◼ It is view which group many item and display them in vertical scrollable
list.
◼ A very common example of ListView is your phone contact book,
◼ List of scrollable items can be displayed in Android using ListView.
◼ it helps you to displaying the data in the form of a scrollable list.
◼ Users can then select any list item by clicking on it.
◼ ListView is default scrollable so we do not need to use scroll View or
anything else with ListView.
ATTRIBUTE AND DESCRIPTION
◼ android:id
➔ This is the ID which uniquely identifies the layout.
◼ android:divider
➔ This is drawable or color to draw between list items.
Q- EXPLAIN Grid view.
◼ In android GridView is a view group that display items in two
dimensional scrolling grid (rows and columns),
◼ the grid items are not necessarily predetermined but they are
automatically inserted to the layout using a ListAdapter.
31
(Affiliated to Saurashtra University & Gujarat Technological University)
◼ Users can then select any grid item by clicking on it. GridView is default
scrollable so we don’t need to use ScrollView or anything else
with GridView.
◼ GridView is widely used in android applications. An example of
GridView is your default Gallery, where you have number of images
displayed using grid.
◼ Gridview is present inside Containers. From there you can drag and drop
on virtual mobile screen to create it. Alternatively you can
also XML code to create it.
ATTRIBUTE AND DESCRIPTION
◼ android:numColumns: This attribute of GridView will be used to
decide the number of columns that are to be displayed in Grid.
◼ android:horizontalSpacing: This attribute is used to define the spacing
between two columns of GridView.
◼ android:verticalSpacing: This attribute is used to specify the spacing
between two rows of GridView.
◼ android:id: This is the ID which uniquely identifies the layout.
◼ android:columnWidth: This specifies the fixed width for each
column.
Q- EXPLAIN fragment.
◼ Android Fragment is the part of activity, it is also known as sub-
activity.
◼ There can be more than one fragment in an activity. Fragments represent
multiple screen inside one activity.
32
(Affiliated to Saurashtra University & Gujarat Technological University)
◼ Android fragment lifecycle is affected by activity lifecycle because
fragments are included in activity.
◼ The FragmentManager class is responsible to make interaction between
fragment objects.
◼ It is the modular section of the android activity that is very helpful in
creating UI designs that are flexible in nature and auto-adjustable based
on the device screen size.
Types of Android Fragments
◼ Single Fragment: Display only one single view on the device screen.
This type of fragment is mostly used for mobile phones.
◼ List Fragment: This Fragment is used to display a list-view from
which the user can select the desired sub-activity.
33
(Affiliated to Saurashtra University & Gujarat Technological University)
Q- what is layout ? How many types of Layouts are available in
android?
Ans.
◼ A layout defines the structure for a user interface in your app, such as in
an activity.
◼ Layout basically refers to the arrangement of elements on a page these
elements are likely to be images, texts or styles.
◼ Relative Layout, Linear Layout, Table Layout etc
Q. EXPLAIN liner layout.
◼ We use this layout to place the elements in a linear manner
◼ A Linear manner means one element per line.
◼ LinearLayout is a view group that aligns all children in a single direction,
vertically or horizontally.
◼ we can specify the layout direction with the android:orientation attribute.
◼ there are two category of liner layout like vertically and horizontal.
➔ Attributes
◼ Android:id- this is id which is define uniquely the layout.
◼ Android:divider:- We use a color value in form of #RGB or
many more.
◼ Android:Gravity:- this specifies how an object should position
its content, on both X andY axes. Possible values are top bottom
left right.
34
(Affiliated to Saurashtra University & Gujarat Technological University)
◼ Android:orientation:- this specifies direction of arrangement.
By default is horizontal.
Q- Explain Relative layout.
◼ A RelativeLayout is a very powerful utility for designing a user interface
because it can eliminate nested view groups and keep your layout
hierarchy flat, which improves performance.
◼ If you find yourself using several nested LinearLayout groups, you may
be able to replace them with a single RelativeLayout .
➔ Attributes:-
◼ android:id: It uniquely identifies the Android Layout.
◼ android:layout_height: It sets the height of the layout.
◼ android:layout_width: It sets the width of the layout.
◼ android:layout_gravity: It sets the position of the child view.
Q- explain table layout.
◼ TableLayout is a ViewGroup subclass, used to display the child View
elements in rows and columns.
➔ Attributes:-
◼ android:id: It uniquely identifies the Android Layout.
35
(Affiliated to Saurashtra University & Gujarat Technological University)
◼ android:layout_height: It sets the height of the layout.
◼ android:layout_width: It sets the width of the layout.
◼ android:layout_gravity: It sets the position of the child view.
Q-explain constraint layout
◼ most of application use this types of layout.
◼ A ConstraintLayout is similar to a RelativeLayout, but having more
power.
➔ Attributes:-
◼ android:id: It uniquely identifies the Android Layout.
◼ android:layout_height: It sets the height of the layout.
◼ android:layout_width: It sets the width of the layout.
◼ android:layout_gravity: It sets the position of the child view.
Q- Explain dialogs box or explain alert dialog box in android.
◼ A dialog is a small window that prompts the user to make a decision or
enter additional information.
◼ A dialog doesn't fill the screen and is normally used for modal events that
require users to take an action before they can proceed.
➔ Alert dialog box:-
◼ They are used to help user answer question, make selection, confirm
actions and read warning or error message.
◼ Alert Dialog shows the Alert message and gives the answer in the form
of yes or no.
◼ Alert Dialog displays the message to warn you and then according to
your response, the next step is processed.
◼ Android Alert Dialog is built with the use of three fields: Title,
Message area, and Action Button.
36
(Affiliated to Saurashtra University & Gujarat Technological University)
Alert Dialog code has three methods:
◼ setTitle() method for displaying the Alert Dialog box Title
◼ setMessage() method for displaying the message
◼ setIcon() method is used to set the icon on the Alert dialog box.
◼ There are three types of alert box like one button , two button, and three
button.
◼ Alert dialog has positive and negative button or message view.
Q- Explain animation in detail.
◼ Animation is the process of creating motion and shape change.
◼ These are used when the ui change state, such as when new content
loads.
◼ Animation also add a polished look to our app,which give it higher
quality look and feel.
◼ We can change image move, move image, size increase and decrease of
image.
➔ Drawing animation and working with animation
◼ There are two types of drawing and working animation like
frame by frame animation and twined animation.
➔ Frame by frame animation:- in this we can swapping
frame repeatedly so it appears continuous to the human
eyes.
◼ Using this we can swap image and change the position of
image.
◼ Its working in only image.
37
(Affiliated to Saurashtra University & Gujarat Technological University)
◼ W can not crate our shape and all other.
➔ Twined animation:-
◼ A tween animation can perform a series of simple transformations
(position, size, rotation, and transparency) on the contents of a View
object.
◼ So, if you have a TextView object, you can move, rotate, grow, or
shrink the text. If it has a background image, the background image
will be transformed along with the textTypes of animation
➔ Other types of animation
◼ Scale animation:- used to make a smaller or larger view either
on x and y axis.(Small to big or big to small)
◼ Rotate animation:- it is used to rotate view around pivot point
a certain number of degree. (rotate clock and anti clock wise)
◼ Translate animation:-used to move view along the x or y axis.
(Marquee type).
◼ Alpha animation:- transparency of view can be
changed.(visible 1 or un visible 0)
➔ Attribute
◼ Android:duration=1000(time in mili second) :- the
duration in which animation is completed.
◼ Android:fillafter=true:- define whether the view should
be visible or not at the end of the animation.
◼ Android:startoffset:- refer the waiting time before an
animation start.(if we give 2 second time so animation
display and start after 2 second .waiting time given)
◼ Android: interpolator:- refer to rate of change in
animation.(speed of changing animation is speed or
slow).
◼ Android: repeatmode: mode of repetition.(cycle or
uncycle) .
38
(Affiliated to Saurashtra University & Gujarat Technological University)
39