0% found this document useful (0 votes)
579 views42 pages

Question Bank

The document discusses various aspects of Android including its features, history, architecture and development tools. Some key points: - The main features of Android are Near Field Communication, a beautiful UI, storage and battery swap capabilities, messaging support, a web browser, and WiFi direct. - Android's architecture includes applications, an application framework, the Android runtime and Dalvik virtual machine, libraries, and the Linux kernel. - Important Android development tools are the SDK, platform tools, and Android Studio which allow managing devices and projects and updating the SDK.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
579 views42 pages

Question Bank

The document discusses various aspects of Android including its features, history, architecture and development tools. Some key points: - The main features of Android are Near Field Communication, a beautiful UI, storage and battery swap capabilities, messaging support, a web browser, and WiFi direct. - Android's architecture includes applications, an application framework, the Android runtime and Dalvik virtual machine, libraries, and the Linux kernel. - Important Android development tools are the SDK, platform tools, and Android Studio which allow managing devices and projects and updating the SDK.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 42

Q1] List the features of Android.

Ans. The features of Android are :


i. Near Field Communication (NFC)
ii. Beautiful UI
iii. Storage and battery swap
iv. Messaging Support
v. Web browser
vi. WiFi: direct

Q2]Explain Android features.


Ans.
a) Near Field Communication (NFC) :-
Most Android devices support NFC, which allows electronic devices to interact
across short distances easily. The main goal here is to create a payment option
that is simpler than carrying cash or credit cards, and while the market hasn't
exploded as many experts had predicted, there may be an alternative in the
works, in the form of Bluetooth Low Energy (BLE).
b) Beautiful UI :-
Android UI design involves the use of prebuilt Android UI components, such as
structured layout objects and UI controls, to build the graphical user interface for
our applications.
c) Storage and Battery Swap :-
Android phones also have unique hardware capabilities. Google's OS makes it
possible to upgrade, replace, and remove your battery that no longer holds a
charge. In addition, Android phones come with SD card slots for expandable
storage.
d) Wi-Fi direct :-
Wi-Fi Direct (also known as peer-to-peer or P2P) allows your application to
quickly find and interact with nearby devices, at a range beyond the
capabilities of Bluetooth. The Wi-Fi Direct (P2P) APIs allow applications to
connect to nearby devices without needing to connect to a network or hotspot.

Q3] History of Android and development tools.


Ans.
October, 2003
- Andy Rubin founded Android Incorporation in California, United
States.
- Operating system for camera.

August, 2005
- Google acquired android Incorporation.
- Rumors a g1 Phone is about to come out.

2007
- Google Announced to introduce Open source O.S.
- Also created Open Handset Aliance.

2008
- The public version Android SDK 1.0 is released.
- World first Android Phone G1 phone manufactured bt HTC.

2009
- New version of the operating system are released: Cupcake(1.5),
Donut(1.6) and Éclair(2.0 and 2.1).

2010
- Android is second only to BlueBerry as the best selling smart
phone platform.

2011
- Android is the #1 mobile platform by number of new activations
and number of devices sold.

Q4] Explain Android architecture.


Ans.
Android architecture contains different number of components to support
any android device needs.

Applications
Applications is the top layer of android architecture. The pre-installed
applications like home, contacts, camera, gallery etc and third party
applications downloaded from the play store like chat applications, games
etc. will be installed on this layer only.

Application framework

Application Framework provides several important classes which are used to


create an Android application. It provides a generic abstraction for hardware
access and also helps in managing the user interface with application
resources. Generally, it provides the services with the help of which we can
create a particular class and make that class helpful for the Applications
creation.

Application runtime
Android Runtime environment is one of the most important part of Android. It
contains components like core libraries and the Dalvik virtual machine(DVM).
Mainly, it provides the base for the application framework and powers our
application with the help of the core libraries.

Like Java Virtual Machine (JVM), Dalvik Virtual Machine (DVM) is a register-
based virtual machine and specially designed and optimized for android to
ensure that a device can run multiple instances efficiently
Libraries
The Platform Libraries includes various C/C++ core libraries and Java based
libraries such as Media, Graphics, Surface Manager, OpenGL etc. to provide a
support for android development.

 SQLite provides database support and FreeType provides font support.


 Web-Kit This open source web browser engine provides all the
functionality to display web content and to simplify page loading.
Linux Kernel
Linux Kernel is heart of the android architecture. It manages all the available
drivers such as display drivers, camera drivers, Bluetooth drivers, audio drivers,
memory drivers, etc. which are required during the runtime.

The Linux Kernel will provide an abstraction layer between the device
hardware and the other components of android architecture. It is responsible
for management of memory, power, devices etc.

Q5] List Android versions.

Cupcake 1.5

Donut 1.6

Eclair 2.0 - 2.1

Froyo 2.2 - 2.2.3

Gingerbread 2.3 - 2.3.7

Honeycomb 3.0 - 3.2.6

Ice Cream Sandwich 4.0 - 4.0.4

Jelly Bean 4.1 - 4.3.1

KitKat 4.4 - 4.4.4


Q6] Explain Android Development Tools(ADT)
Ans. Android is a development tool that lets you perform these tasks:
Manage Android Virtual Devices (AVD)
Create and update Android projects
Update your sdk with new platform add-ons and documentation

SDK tools: SDK tools are generally platform independent and are required no
matter which android platform you are working on. When you install the
Android SDK into your system, these tools get automatically installed.

Platform tools: The platform tools are customized to support the features of the
latest android platform. The platform tools are typically updated every time you
install a new SDK platform. Each update of the platform tools is backward
compatible with older platforms.

Q7] Explain OS and its types.


Ans.
- 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 developed by a partnership of developers known as the Open
Handset Alliance and commercially sponsored by Google.
- Android OS is a Linux-based mobile operating system that primarily runs on
smartphones and tablets.
- The Android platform includes an operating system based upon the Linux
kernel, a GUI, a web browser and end-user applications that can be
downloaded.

Q8] Explain SDK and JDK.


Ans.
i. SDK
A software development kit (SDK) is a set of software tools and programs
provided by hardware and software vendors that developers can use to
build applications for specific platforms. SDKs help developers easily
integrate their apps with a vendor's services. SDKs include documentation,
application programming interfaces (APIs), code samples, libraries and
processes, as well as guides that developers can use and integrate into
their apps. Developers can use SDKs to build and maintain applications
without having to write everything from scratch.

ii. JDK

JDK is an acronym for Java Development Kit. The Java Development Kit
(JDK) is a software development environment which is used to develop
java applications and applets. It physically exists. It contains JRE +
development tools. The JDK contains a private Java Virtual Machine (JVM)
and a few other resources such as an interpreter/loader (Java), a
compiler (javac), an archiver (jar), a documentation generator (Javadoc)
etc. to complete the development of a Java Application.

Q9] State the advantages and disadvantages of DVM.


Ans.
Advantages
 DVM supports the Android operating system only.
 In DVM executable is APK.
 Execution is faster.
 From Android 2.2 SDK Dalvik has it’s own JIT (Just In Time) compiler.
 DVM has been designed so that a device can run multiple instances
of the Virtual Machine effectively.
 Applications are given their own instances.

Disadvantages
 DVM supports only Android Operating System.
 For DVM very few Re-Tools are available.
 Requires more instructions than register machines to implement the
same high-level code.
 App Installation takes more time due to dex.
 More internal storage is required.

Q10] Explain DVM in detail.


Ans.

- 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.
- Dalvik is a name of a town in Iceland. The Dalvik VM was written by Dan
Bornstein.
- The Java Compiler(javac) converts the Java Source Code into Java
Byte-Code(.class). Then DEX Compiler converts this (.class) file into in
Dalvik Byte Code i.e. “.dex” file.

Q11] Explain main components in developing an android application?


Ans.
 Android component is simply a piece of code that has a well defined life
cycle.
 Activity: An activity is a class that represent a single screen. It is like a
Frame in AWT.
 View: A view is the element such as button, label. Text field etc. Anything
that you see is a view.
 Intent: Intent is used to invoke components. It is mainly used to:
- Start a service.
- Launch an activity.
- Display a web page
- Display a list of contact
- Broadcast a message
- Dial a phone call etc
 Service: Service is a background process that can run for a long time.
There are two types of service is accessed from within the application
whereas remote service is accessed remotely from other applications
running on the same device.
 Fragment: Fragments are like parts of activity. An activity can display one
or more fragments on the screen at the same time.

Q12] Explain Android application structure?


Ans.

 AndroidManifest.xml:
Every project in android includes a manifest file, which is
AndroidManifest.xml, stored in the roor directory of its project hierarchy.
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.

 Res:
The 'res' stands for Resource file. It can store resource files such as pictures,
XML files, etc. It contains some additional folders such as Drawable,
Layout and Values.

 Drawable:
A drawable folder contains resource type file (something that can be
drawn). Drawable may take a variety of file Bitmap (PNG, JPEG), Nine
Patch, Vector (XML), Shape, Layers, States, Levels and Scale.

 Mipmap:
Mipmap folder contains the image Asset file can be used in Android
studio application. You can generate the following 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 indentified by a u nique name that can be in
the android application program.

 Build.gradle(Module: app):
This defines that module-specific build configuration. Here you can add
dependancies what you need in your android application.
Q.13. Explain UI components
Ans: UI (User Interface) components are the building blocks of any Android
application's interface. They are responsible for creating the interactive user
interface that the user can interact with. The Android platform provides a variety
of UI components that developers can use to create the desired interface for
their applications. Here are some of the most common UI components used in
Android:
1. TextView: A TextView is a UI component used to display text on the screen.
It can display either a single line of text or multiple lines of text.
Syntax : :- <Linear Layout xmls:android=
"http://schemas.android.com/apk/res/android"
<TextView
//attributes to describe it
/>
</LinearLayout>

2. EditText: An EditText is a UI component used to accept user input. It allows


the user to enter text, numbers, or symbols.
Syntax :- <Linear Layout
xmls:android= ”http://schemas.android.com/apk/res/android”>
<EditText
//attributes
>
</LinearLayout>

3. Button: A Button is a UI component used to initiate an action when the user


clicks on it. It can be used to submit a form, start a new activity, or perform
any other action.
Syntax :- <Linear Layout
xmls:android= ”http://schemas.android.com/apk/res/android”>
<Button
//attributes
/>
</LinearLayout>

4. ToggleButton :- The toggle button displays the ON/OFF states of a button


with a light indicator

5. ImageButton: An ImageButton is a UI component that displays an image


on the screen. It can be used to create a custom button with an image instead
of text.
Syntax :- <Linear Layout
xmls:android= ”http://schemas.android.com/apk/res/android”>

<ImageButton
//other attributes...
android:src= “@drawable/add_icon”/>

</LinearLayout>
6.ImageView: An ImageView is a UI component used to display images on
the screen. It can be used to display images from a local file or from the
internet.

7.CheckBox: A CheckBox is a UI component used to select one or more


options from a list of options. It can be used to create a list of options for the
user to select from.
Syntax :- <Linear Layout
xmls:android= ”http://schemas.android.com/apk/res/android”>
<CheckBox
android:checked="true"
android:text="CheckBox"
// other attributes
/>
</LinearLayout>

8. RadioButton: A RadioButton is a UI component used to select one option


from a list of options. It can be used to create a list of options where only
one option can be selected.
Syntax :- <Linear Layout
xmls:android= ”http://schemas.android.com/apk/res/android”>
<RadioButton
android:text="Radio button"
android:checked="true"/>
</LinearLayout>

9. RadioGroup : It’s a group of Radio buttons that are alike. In this, only one of
all the buttons can be chosen.
Syntax :- <Linear Layout
xmls:android= ”http://schemas.android.com/apk/res/android”>

<RadioGroup android:orientation="vertical">
<RadioButton android:text="Radio Button 1"/>
<RadioButton android:text="Radio Button 2"/>
<RadioButton android:text="Radio Button 3"/>
</RadioGroup>

</LinearLayout>
10. Spinner: A Spinner is a UI component used to display a drop-down list of
options. It can be used to create a list of options where the user can select
one option.

11. ProgressBar: In Android, we have a progress bar that shows the progress of
some action that is happening like pasting a file to some location. A
progress bar can be in two modes:

 Determinate Mode:
In this, the progress is shown with the percent of action completed.
Also, the time to be taken is already determined.

 Indeterminate Mode:
In this, there is no idea of when the task would be completed,
therefore, it functions continuously.

Syntax :- <Linear Layout


xmls:android=”http://schemas.android.com/apk/res/android”>
<ProgressBar
// attributes, here we define the speed, layout, id, etc.
/>
</LinearLayout>

12. TimePicker :-Time picker is a UI component that works as an intermediate


to select a time of the day. The time chosen by it is shown either in 24 hrs format
or in 12hrs format using AM and PM.

It gives a virtual Clock/watch to select it. This virtual clock makes it easy to
choose the time.

13.DatePicker :- Like we have time picker, we have a date picker as UI control


too. In this, the System shows a virtual calendar to the users to choose the day.

This enables the user to choose a particular date using either a calendar or a
dropdown. These both are made to make it easier for the user to pick up a date
and a time.
14. AutoCompleteTextView:- AutoCompleteTextView is an extension of EditText.
In this UI element, the user is provided with a few suggestions of some
values/texts. The value can be chosen by the user while filling
AutoCompleteTextView.

Q. 14. Enlist the different types of layouts in UI design

- Linear Layout

- Relative Layout

- Table Layout

- Absolute Layout
- Frame Layout

Q.15. What is LinearLayout? List its attributes and give an example

LinearLayout is a type of layout in Android that arranges UI components in a


single row or column, depending on the orientation specified. It is the simplest
and most commonly used layout in Android. The orientation can be horizontal
or vertical, and the UI components can be arranged in the order they appear
in the layout file.

Attributes :

 android:id
 android:baselineAligned
 android:gravity
 android:orientation
 android:divider

 android:layout_width

Example :-
<LinearLayout

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:orientation="vertical">

<TextView

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="Hello World!" />

<Button

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:text="Click me!" />

</LinearLayout>

Q. 16. What is AbsoluteLayout? List its examples and give an example

AbsoluteLayout is a type of layout in Android that allows UI components to be


positioned at specific coordinates on the screen. It gives developers precise
control over the positioning of UI components, but it is not recommended for
general use as it can cause layout issues on different screen sizes and densities.
Attributes :-

 android:id
 android:layout_x
 android:layout_y
 android:layout_width
 android:layout_height

Example :-
<AbsoluteLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="Hello World!"
android:layout_x="50dp"
android:layout_y="50dp" />

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click me!"
android:layout_x="150dp"
android:layout_y="150dp" />

</AbsoluteLayout>

Q. 17. What is RelativeLayout? List its examples and give an example


RelativeLayout is a type of layout in Android that allows UI components to be
positioned relative to each other or to the parent layout. It is flexible and can
adapt to different screen sizes and densities, making it suitable for general use in
Android app development.

Attributes :-
 android:layout_width
 android:layout_height
 android:id
 android:gravity
 android:ignoreGravity
Example :-
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click me!"
android:layout_below="@+id/textView1"
android:layout_centerHorizontal="true" />
</RelativeLayout>

Q. 18. What is FrameLayout? List its examples and give an example


FrameLayout is a type of layout in Android that is designed to display a single
item at a time. It is useful when you want to display one view on top of another
view, such as an image on top of a background. FrameLayout is a lightweight
and efficient layout, but it is not suitable for complex layouts with multiple UI
components.

Attributes :-
 android:layout_width
 android:layout_height
 android:id
 android:foreground
Example :-
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/background_image" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:textSize="24sp"
android:layout_gravity="center" />
</FrameLayout>

Q. 19. What is TableLayout? List its examples and give an example


TableLayout is a type of layout in Android that is used to display data in a table
format, with rows and columns. It is a flexible and easy-to-use layout that can be
used to create simple or complex tables. TableLayout can be a good choice for
displaying data in a structured way, such as in a schedule, a leaderboard, or a
list of items.

Attributes :-
 android:layout_width
 android:layout_height
 android:id
 android:collapseColumns
 android:shrinkColumns
Examples :-
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow>
<TextView
android:text="Name"
android:textStyle="bold"
android:padding="5dp" />
<TextView
android:text="Description"
android:textStyle="bold"
android:padding="5dp" />
<TextView
android:text="Price"
android:textStyle="bold"
android:padding="5dp" />
</TableRow>

<TableRow>
<TextView
android:text="Item 1"
android:padding="5dp" />
<TextView
android:text="Description of item 1"
android:padding="5dp" />
<TextView
android:text="$10"
android:padding="5dp" />
</TableRow>
<TableRow>
<TextView
android:text="Item 2"
android:padding="5dp" />
<TextView
android:text="Description of item 2"
android:padding="5dp" />
<TextView
android:text="$15"
android:padding="5dp" />
</TableRow>
</TableLayout>

Q. 20. Explain TextView and EditText


TextView and EditText are two UI components that are used to display and edit
text, respectively.
TextView is a UI component that is used to display text to the user. It can be used
to display a label, a message, or any other type of text content .TextView can
be customized in various ways, including its text size, color, font, and alignment.
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:textSize="24sp"
android:textColor="#000000"
android:gravity="center" />
EditText is a Widget of user interface (UI) used to retrieve and modify text data
from a user in an Android app. EditText is a subclass of TextView that inherit all
the property of TextView. Nowadays, EditText is represented with the PlainText
element in UI, which displays an empty text field while designing the app.
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
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter your name"
android:inputType="text"
android:textColor="#000000"
android:textSize="16sp" />

Q. 21. List different attributes of TextView and EditText


TextView :-
 android:layout_width
 android:layout_height
 android:id
 android:capitalize
 android:gravity
 android:hint
 android:inputType
 android:text
 android:textColor
 android:textSize
 android:textStyle
 android:password
EditText :-
 android:layout_width
 android:layout_height
 android:id
 android:gravity
 android:hint
 android:inputType
 android:text
 android:textColor
 android:textSize
 android:textStyle
 android:background
 android:backgroundTint
 android:width
 android:height

23. List different attributes of CheckBox and ProgressBar in UI design


Ans:
Attributes of CheckBox:
android:id: Specifies a unique ID for the CheckBox.
android:layout_width: Specifies the width of the CheckBox.
android:layout_height: Specifies the height of the CheckBox.
android:text: Specifies the text label associated with the CheckBox.
android:checked: Specifies whether the CheckBox is initially checked or
unchecked.
android:enabled: Specifies whether the CheckBox is initially enabled or disabled.
android:visibility: Specifies whether the CheckBox is initially visible or invisible.
android:focusable: Specifies whether the CheckBox can be focused or not.
android:onClick: Specifies a method to call when the CheckBox is clicked.

Attributes of ProgressBar:
android:id: Specifies a unique ID for the ProgressBar.
android:layout_width: Specifies the width of the ProgressBar.
android:layout_height: Specifies the height of the ProgressBar.
android:max: Specifies the maximum value for the ProgressBar.
android:progress: Specifies the initial progress value for the ProgressBar.
android:secondaryProgress: Specifies the secondary progress value for the
ProgressBar.
android:indeterminate: Specifies whether the ProgressBar is in the indeterminate
state or not.
android:visibility: Specifies whether the ProgressBar is initially visible or invisible.
android:style: Specifies the style of the ProgressBar.
24. Explain RadioButton and RadioGroup with example
Ans:
 RadioButton and RadioGroup are UI components in Android that are used to
provide users with a set of mutually exclusive options to choose from.
 RadioButton is a button that represents a single choice among a set of
options. It can be selected or unselected by the user, and only one
RadioButton can be selected at a time.
 RadioGroup is a container that holds multiple RadioButtons and ensures that
only one RadioButton in the group is selected at a time. When a RadioButton
is selected, the previously selected RadioButton in the same group is
automatically deselected.
 Here's an example of how to use RadioButton and RadioGroup in Android:
1. In the XML file, define a RadioGroup and multiple RadioButton elements
inside it, each with a unique ID and a text label:
<RadioGroup
android:id="@+id/radio_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<RadioButton
android:id="@+id/radio_button_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Option 1" />
<RadioButton
android:id="@+id/radio_button_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Option 2" />

<RadioButton
android:id="@+id/radio_button_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Option 3" />

</RadioGroup>
2. In the Java code, get a reference to the RadioGroup and set an
OnCheckedChangeListener to handle changes in the selection:
RadioGroup radioGroup = findViewById(R.id.radio_group);

radioGroup.setOnCheckedChangeListener(new
RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
// Do something when a RadioButton in the group is selected
RadioButton radioButton = findViewById(checkedId);
String selectedOption = radioButton.getText().toString();
Toast.makeText(MainActivity.this, "Selected option: " + selectedOption,
Toast.LENGTH_SHORT).show();
}
});

25. List attributes of RadioButton and RadioGroup


Ans:
Attributes of RadioButton:
android:id: Specifies a unique ID for the RadioButton.
android:layout_width: Specifies the width of the RadioButton.
android:layout_height: Specifies the height of the RadioButton.
android:text: Specifies the text label associated with the RadioButton.
android:checked: Specifies whether the RadioButton is initially selected or not.
android:enabled: Specifies whether the RadioButton is initially enabled or
disabled.
android:visibility: Specifies whether the RadioButton is initially visible or invisible.
android:focusable: Specifies whether the RadioButton can be focused or not.
android:onClick: Specifies a method to call when the RadioButton is clicked.
Attributes of RadioGroup:
android:id: Specifies a unique ID for the RadioGroup.
android:layout_width: Specifies the width of the RadioGroup.
android:layout_height: Specifies the height of the RadioGroup.
android:orientation: Specifies the orientation of the RadioGroup. It can be
"horizontal" or "vertical".
android:checkedButton: Specifies the ID of the RadioButton that is initially
selected.
android:enabled: Specifies whether the RadioGroup is initially enabled or
disabled.
android:visibility: Specifies whether the RadioGroup is initially visible or invisible.
android:onCheckedChanged: Specifies a method to call when the selection in
the RadioGroup changes.
android:addStatesFromChildren: Specifies whether the RadioGroup should add
state (pressed, focused, etc.) from its children to its own state.

26. Explain GridView and ListView controls


Ans:
GridView and ListView are two commonly used UI controls in Android for
displaying a list of items to the user.
ListView:
- ListView is a UI component in Android that is used to display a vertical list
of scrollable items. Each item in the list is an instance of a view that can
be customized as per the requirement. ListView is used when we have a
large number of items to be displayed to the user in a scrollable list. The
items can be displayed in a single column or in multiple columns.
GridView:
- GridView is a UI component in Android that is used to display a two-
dimensional scrolling grid of items. Each item in the grid is an instance of a
view that can be customized as per the requirement. GridView is used
when we want to display items in a grid-like structure. The items are
arranged in columns and rows, and the user can scroll vertically or
horizontally to view all the items.
- Both ListView and GridView require an Adapter to provide data to the UI
control. The adapter is responsible for creating views for each item in the
list or grid and binding the data to those views.
In summary, ListView is used for displaying a scrollable list of items, whereas
GridView is used for displaying a two-dimensional grid of items.

27. List different adapters used in UI design of GridView and ListView controls
Ans:
In Android, adapters are used to bind data to UI components such as GridView
and ListView controls. Here are the different types of adapters used in the UI
design of GridView and ListView controls:
- ArrayAdapter: This adapter is used to bind an array of data to a UI
component such as a ListView or Spinner.
- SimpleAdapter: This adapter is used to bind data in the form of a list of
Maps to a UI component such as a ListView.
- BaseAdapter: This is a more flexible adapter that allows us to create
custom adapters to bind data to a UI component such as a ListView or
GridView.
- CursorAdapter: This adapter is used to bind data from a database query
to a UI component such as a ListView.
- RecyclerView.Adapter: This adapter is used to bind data to a
RecyclerView, which is a more modern and flexible replacement for the
ListView and GridView controls.
Each of these adapters has its own strengths and weaknesses, and the choice
of which one to use depends on the specific needs of the application.

28. Explain parameters related to custom toast (parameters of method)


Ans:
- In Android, a Toast is a small pop-up message that appears on the screen to
give feedback to the user. Android provides a default Toast implementation,
but we can also create a custom Toast using our own layout and display it on
the screen.
- To create a custom Toast, we use the Toast class and its makeText() method.
The makeText() method takes several parameters that allow us to customize
the appearance and behavior of the Toast message. Here are the
parameters related to custom Toast:
 Context: This parameter specifies the context of the application, typically
the activity that is creating the Toast. It is a required parameter and
cannot be null.
 Message: This parameter specifies the message to be displayed in the
Toast. It can be a string resource or a plain string. It is a required
parameter and cannot be null.
 Duration: This parameter specifies the length of time the Toast message
should be displayed on the screen. It can be either LENGTH_SHORT or
LENGTH_LONG.
 Gravity: This parameter specifies the position of the Toast message on the
screen. It can be set to one of the predefined values such as Gravity.TOP,
Gravity.BOTTOM, Gravity.CENTER, etc.
 X-offset and Y-offset: These parameters specify the horizontal and vertical
offset of the Toast message from the center of the screen. They are
optional parameters and can be set to 0 if not required.
 View: This parameter allows us to use a custom layout to display the Toast
message. We can create a custom layout using XML and inflate it using
LayoutInflater.
- To create a custom Toast, we can pass a custom layout as the View
parameter. The custom layout should have a TextView or an ImageView to
display the message or image. We can also customize the background color,
font size, and other attributes of the layout to match the theme of the
application.
- In summary, the parameters of the makeText() method in Android allow us to
customize the appearance and behavior of the Toast message. We can
specify the context, message, duration, gravity, offset, and custom layout to
create a custom Toast message.
29. List different attributes of DatePicker in UI design
Ans:
1. android:datePickerMode: This attribute allows us to set the mode of the
DatePicker. It can be set to "calendar" for a calendar-based DatePicker or
"spinner" for a dropdown spinner-based DatePicker.

2. android:headerBackground: This attribute sets the background color or


drawable for the DatePicker header.

3. android:calendarTextColor: This attribute sets the color of the text displayed


in the DatePicker calendar.

4. android:calendarTextColorFocused: This attribute sets the color of the text


displayed in the DatePicker calendar when focused.

5. android:calendarTextColorSelected: This attribute sets the color of the text


displayed in the DatePicker calendar when a date is selected.
6. android:dayOfWeekBackground: This attribute sets the background color or
drawable for the day of the week headers in the DatePicker.

7. android:dayOfWeekTextAppearance: This attribute sets the text appearance


for the day of the week headers in the DatePicker.

8. android:dayBackground: This attribute sets the background color or


drawable for each day in the DatePicker calendar.

9. android:dayTextAppearance: This attribute sets the text appearance for


each day in the DatePicker calendar.

10. android:minDate: This attribute sets the minimum selectable date in the
DatePicker.

11. android:maxDate: This attribute sets the maximum selectable date in the
DatePicker.

12. android:startYear: This attribute sets the start year for the DatePicker calendar.

13. android:endYear: This attribute sets the end year for the DatePicker calendar.

14. android:yearListItemTextAppearance: This attribute sets the text appearance


for each year in the year spinner.

15. android:yearListSelectorColor: This attribute sets the color of the background


when a year is selected in the year spinner.

30. Explain implicit intent


Ans:
- In Android, an intent is a messaging object that can be used to
communicate between components of an application, or between different
applications. An implicit intent is a type of intent that does not specify the
exact component to be invoked but instead declares an action to be
performed, and allows the system to choose the appropriate component to
handle the action.
- When we create an implicit intent, we specify the action that we want to
perform, such as sending an email or opening a website. The Android system
then searches for components that can perform that action and displays a
list of available options to the user. The user can then choose which
component they want to use to perform the action.
- For example, if we want to open a web page, we can create an implicit
intent with the ACTION_VIEW action and the URL of the web page as the
data. When we start this intent, the Android system will display a list of web
browsers installed on the device and allow the user to choose which browser
they want to use to open the web page.
- In summary, an implicit intent in Android allows us to declare an action to be
performed without specifying the exact component to be invoked. The
Android system then chooses the appropriate component to handle the
action based on the available options on the device.

31] Explain explicit intent


Ans: In Android development, explicit intent refers to an intention or action that
is explicitly stated and targeted to a specific component within an application
or another application. It is a type of intent that is used to start a specific activity
or service within the same app or a different app.
Explicit intents contain a component name or class that specifies the target
activity or service that the intent is intended to start. For example, if an app
wants to open a new activity, it would create an explicit intent that includes the
name of the activity to be started.
Here is an example of how to create an explicit intent to start a new activity
within the same app:
Intent intent = new Intent(MainActivity.this, SecondActivity.class);
startActivity(intent);
In this example, MainActivity.this is the context of the current activity, and
SecondActivity.class is the target activity that the explicit intent is intended to
start. The startActivity() method is then used to initiate the intent and start the
new activity.
Overall, explicit intents are commonly used in Android development to facilitate
communication between components within an app or between different apps.
They provide a straightforward and precise way to initiate actions and transitions
within an application.

32] Write syntax of Intent in Android (2)


Ans: An Intent is a messaging object that is used to communicate between
different components of an application, such as activities, services, and
broadcast receivers. It is a fundamental concept in Android and is used for a
variety of purposes, such as starting a new activity, launching a service, sending
data between activities or services, and broadcasting system events to other
components.
Syntax of intent :
- Intent intent = new Intent(context, TargetActivity.class);
In this syntax, context refers to the current context of the application, such as the
current activity or service that is creating the intent. TargetActivity.class refers to
the activity or service that the intent is intended to start or communicate with.

we can also add additional information to the Intent using various methods,
such as:
- intent.putExtra(key, value);
This method is used to add extra data to the intent, where key is a string that
identifies the data and value is the actual data you want to include.
- intent.setAction(action);
This method is used to set the action of the intent, which defines the type of
operation that the intent is intended to perform.
- intent.setData(uri);
This method is used to set the data URI of the intent, which specifies the data
that the intent is intended to operate on.
Overall, the Intent syntax in Android provides a flexible and powerful way to
initiate actions and communicate between different components within an app
or between different apps.

33] Explain activity life cycle with neat labelled diagram


Ans: An activity is the single screen in android. It is like window or frame of Java.
Android Activity Lifecycle is controlled by 7 methods of android.app.Activity
class. The android Activity is the subclass of ContextThemeWrapper class.
Following is the diagram of activity lifecycle –

As shown in the diagram, there are several stages in the activity life cycle, which
are:
Created - When an activity is first created, the onCreate() method is called. In
this stage, the activity is initialized and its user interface is created.
Started - After the onCreate() method has been called, the onStart() method is
called. At this stage, the activity becomes visible to the user, but it is not yet in
the foreground.
Resumed - When the activity is brought to the foreground and becomes the
focus of user interaction, the onResume() method is called. This is the stage
where the activity is active and the user can interact with it.
Paused - If another activity is launched on top of the current activity, the
onPause() method is called. In this stage, the activity is still visible to the user, but
it has lost focus and cannot interact with the user.
Stopped - If the activity is no longer visible to the user, the onStop() method is
called. This can happen if the activity is finished or if another activity has taken
over the screen.
Destroyed - When the activity is finished or if the system needs to free up
memory, the onDestroy() method is called. This is the stage where the activity is
completely removed from memory and its resources are released.

34] List different methods of activity life cycle (all methods)


Ans: - onCreate()
- onStart()
- onResume()
- onPause()
- onStop()
- onDestroy()
- onRestart()
35] What is Fragment? (2)
Ans: A Fragment is a modular section of a user interface that can be combined
with other fragments to create a complete activity. Fragments were introduced
in Android 3.0 (API level 11) to address the need for more flexible and dynamic
user interfaces, particularly on larger screens like tablets.
Fragments are like a self-contained sub-activity within an activity, and they have
their own lifecycle that is similar to that of an activity. They can be added,
removed, replaced, or even overlapped with other fragments within an activity.
Some key features and benefits of fragments include:
- Improved modularity and reusability of UI components
- Better support for large-screen and multi-pane user interfaces
- Simplified management of UI state and lifecycle
- Easier navigation and backstack management
- More efficient memory usage, particularly when reusing fragments
To use fragments in an Android application, you need to extend the Fragment
class and override its lifecycle methods, much like you would with an activity.
You can then add fragments to an activity using the FragmentManager and
FragmentTransaction APIs.

36] What is Fragment (or sub-activity) life cycle and its methods?
Ans: The Fragment lifecycle is similar to that of an activity, with some additional
methods that are specific to fragments. Understanding the
Fragment lifecycle is essential for developing robust and
responsive Android applications that use fragments.
Here is a diagram that illustrates the Fragment lifecycle in Android:
As shown in the diagram, there are several stages in the Fragment
lifecycle, which are:
onAttach() - When a fragment is attached to an activity, the
onAttach() method is called. This is where the fragment is
associated with its parent activity, and you can get a reference
to the activity using the getActivity() method.
onCreate() - After the fragment is attached to the activity, the
onCreate() method is called. This is where you can initialize
the fragment, such as setting up UI components and other
resources.
onCreateView() - After the onCreate() method is called, the
onCreateView() method is called. This is where you can inflate
the fragment's layout and set up its user interface.
onActivityCreated() - After the fragment's view hierarchy is
created, the onActivityCreated() method is called. This is where
you can access the parent activity's view hierarchy and set up
any necessary communication between the activity and the
fragment.
onStart() - When the parent activity starts, the onStart() method is
called for the attached fragments. This is where you can start any background
threads or services that the fragment needs.
onResume() - When the parent activity resumes, the onResume() method is
called for the attached fragments. This is where the fragment becomes active
and can interact with the user.
onPause() - If another activity comes to the foreground or the parent activity is
paused, the onPause() method is called for the attached fragments. This is
where the fragment must save its state or stop any background threads or
services.
onStop() - When the parent activity is stopped, the onStop() method is called for
the attached fragments. This is where you should clean up any resources used
by the fragment.
onDestroyView() - When the fragment's view hierarchy is destroyed, the
onDestroyView() method is called. This is where you should release any resources
used by the fragment's UI components.
onDestroy() - After the view hierarchy is destroyed, the onDestroy() method is
called. This is where you should release any resources used by the fragment.
onDetach() - When the fragment is detached from its parent activity, the
onDetach() method is called. This is where the fragment is disassociated from its
parent activity.

37] Explain the concept of service with Service life cycle.


Ans.
- Android service is a component that is used to perform operations on the
background such as playing music, handle network transactions, interacting
content providers etc. It doesn't has any UI (user interface).
- 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.
- The service runs in the background indefinitely even if application is
destroyed.
- Moreover, service can be bounded by a component to perform interactivity
and inter process communication (IPC).
-
1) onStartCommand()
The system calls this method when another component, such as an activity,
requests that the service be started, by calling startService(). If you implement
this method, it is your responsibility to stop the service when its work is done, by
calling stopSelf() or stopService() methods.
2) onBind()
The system calls this method when another component wants to bind with the
service by calling bindService(). If you implement this method, you must provide
an interface that clients use to communicate with the service, by returning
an IBinder object. You must always implement this method, but if you don't want
to allow binding, then you should return null.
3) onUnbind()
The system calls this method when all clients have disconnected from a
particular interface published by the service.
4) onRebind()
The system calls this method when new clients have connected to the service,
after it had previously been notified that all had disconnected in
its onUnbind(Intent).
5) onCreate()
The system calls this method when the service is first created
using onStartCommand() or onBind(). This call is required to perform one-time
set-up.
6) onDestroy()
The system calls this method when the service is no longer used and is being
destroyed. Your service should implement this to clean up any resources such as
threads, registered listeners, receivers, etc.

38] List the different methods of callback methods of Service base class.
Ans.
In Android, the Service class provides several callback methods that allow
developers to manage the life cycle and interactions of the service. Some of
the common callback methods of the Service class are:

onCreate(): This method is called when the service is first created. It is used to
perform any one-time initialization needed for the service.
onStartCommand(): This method is called when the service is started using
startService() method. It is used to handle the intent sent to the service and
perform the desired operation.
onBind(): This method is called when a client binds to the service using
bindService() method. It returns an IBinder object that the client can use to
communicate with the service.
onUnbind(): This method is called when all clients have disconnected from the
service using unbindService() method.
onDestroy(): This method is called when the service is being destroyed. It is used
to release any resources used by the service.
onTaskRemoved(): This method is called when a task that the service is running is
removed from the recent apps list.

These methods provide a way for developers to manage the lifecycle and
interactions of the service and ensure that it performs as expected.

39] Explain concept of multimedia framework.


Ans.
Multimedia framework is an essential part of the Android operating system that
allows developers to create applications that can capture, manipulate, and
play multimedia content such as audio, video, and images.
The multimedia framework in Android consists of several components that work
together to provide a seamless multimedia experience to the user. Some of the
key components of the multimedia framework in Android are:
Media Player: This component allows developers to play audio and video files in
their applications. It supports a wide range of audio and video formats and
provides a simple and easy-to-use interface for controlling playback.
Audio Manager: This component provides access to the audio hardware on the
device and allows developers to control the volume, audio mode, and other
audio-related settings.
Camera: This component allows developers to capture images and video using
the device's camera. It provides a simple and easy-to-use interface for
controlling the camera settings and capturing media.
Media Router: This component allows developers to route audio and video
output to different devices such as headphones, speakers, or a connected TV.
The multimedia framework in Android provides developers with a powerful set of
tools for creating multimedia applications that can play, capture, and
manipulate audio, video, and images. These components work together to
provide a seamless and engaging multimedia experience to the user.
40] Explain different callback methods of MediaPlayer class.
Ans.
An Android activity goes through six major life cycle stages or callbacks. These
are: onCreate(), onStart(), onResume(), onPause(), onStop(), and onDestroy().
The system invokes each of these callbacks as an activity enters a new state.
(1) onCreate() :-
The onCreate() callback is compulsory in all Android applications. It is the first
method called when we launch an activity from the home screen or intent. In
other words, it is a default callback that is automatically created when you
create a new activity.
Android Studio automatically creates a class named the MainActivity.java file.
This class contains an onCreate() callback. It is called when a user first opens the
application.
(2) onStart() :-
When an application is started, the system will invoke an onStart() method. This
callback is invoked to make the activity visible to the user.
onStart() can be called several times during an application’s lifecycle. For
example, this method can be called when a user opens another activity and
then navigates back to the previous activity.
(3) onResume() :-
Once onStart() is called, onResume() is immediately invoked. Every component
associated with this activity is brought to the foreground state.
The activity remains in the foreground state unless something happens to the
application. This may include overly (multi-window mode application)
interaction from other applications such as a phone call or when a user
navigates to another activity.
(4) onPause() :-
onPause() is called when the user switches to another activity or a multi-window
mode application. At this point, the activity has lost focus and is running in the
background.
This callback will pause the activity and release some resources that this activity
was consuming. All un-required operations are paused.
(5) onStop() :-
This life-cycle usually occurs after the onPause() method is executed due to the
user switching to other activities or pressing the home button.
In such situations, it is used to release heavy resources and stop intensive
operations that are not required while the activity is invisible.
Since onPause() is brief, onStop() can be used to save data to other channels
such as databases.

41] Explain how to use camera in Android application.


Ans.
Using the camera in an Android application involves several steps, including
requesting permission to use the camera, opening the camera, capturing
images or videos, and releasing the camera when it is no longer needed. The
following are the general steps to use the camera in an Android application:
1. Request Camera Permission: In the AndroidManifest.xml file, add the
CAMERA permission to the app, and in the Java code, request the
permission at runtime using the requestPermissions() method.
2. Create Camera Preview: To show the camera preview on the screen, create
a SurfaceView or TextureView and attach it to the camera.
3. Open Camera: Use the CameraManager class to get a reference to the
camera and open it using the openCamera() method.
4. Set Camera Parameters: Configure the camera settings such as resolution,
focus mode, flash, and exposure using the Camera.Parameters class.
5. Start Preview: Start the camera preview by calling the setPreviewDisplay()
method, followed by the startPreview() method.
6. Capture Image/Video: To capture an image or video, create a
Camera.CaptureSession and configure it to capture the desired media type
using the CameraCaptureRequest class.
7. Save Media: After capturing the image or video, save it to a file or upload it
to a server.
8. Release Camera: When the camera is no longer needed, release it by
calling the Camera.release() method.
These are the following two ways, in which you can use camera in your
application
- Using existing android camera application in our application

- Directly using Camera API provided by android in our application

Using existing android camera application in our application

- You will use MediaStore.ACTION_IMAGE_CAPTURE to launch an existing


camera application installed on your phone.
- Syntax :-
Intent intent = new
Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);

42] Explain SQLite connectivity in Android.


Ans.
- SQLite is a lightweight and embedded database engine that is widely used
in Android applications.
- It is an open-source, self-contained, and serverless database that stores data
in a single file on the device's file system.
- SQLite provides a simple and efficient way to store and retrieve structured
data in Android applications.
To use SQLite in an Android application, developers need to follow these basic
steps:
1. Create a Database Helper Class: The first step is to create a class that
extends the SQLiteOpenHelper class. This class is responsible for creating
and upgrading the database, as well as providing access to the
database.
2. Define the Database Schema: The database schema is a set of tables,
columns, and constraints that define the structure of the database.
Developers can define the schema using the SQL Data Definition
Language (DDL) in the onCreate() method of the Database Helper class.
3. Open the Database: To access the database, developers need to
create an instance of the Database Helper class and call its
getReadableDatabase() or getWritableDatabase() method, depending
on whether they want to read or write data.
4. Insert, Update, or Delete Data: Once the database is open, developers
can insert, update, or delete data by executing SQL commands using
the SQLiteDatabase class. They can use methods such as insert(),
update(), or delete() to perform these operations.
5. Query Data: To retrieve data from the database, developers can use the
query() method of the SQLiteDatabase class. This method takes several
parameters, including the table name, columns to retrieve, selection
criteria, and sort order.
6. Close the Database: After the database operations are complete,
developers should close the database by calling the close() method of
the SQLiteDatabase class.

43] Explain SMS telephony in Android.


Ans.
- SMS (Short Message Service) telephony is the feature in Android that allows
users to send and receive SMS messages using their Android device. It is an
essential component of the telephony framework that provides the ability to
send and receive text messages over the mobile network.
- To use SMS telephony in an Android application, developers can use the SMS
Manager class. This class provides methods for sending and receiving SMS
messages, as well as for querying the message inbox and outbox. The
following are some of the methods available in the SMS Manager class:
1. sendTextMessage(): This method sends an SMS message to a specified
recipient using the default SIM card in the device. It takes several
parameters, including the recipient's phone number, the message body,
and delivery intent.
2. getDefault(): This method returns an instance of the SMS Manager class
that is associated with the default SIM card in the device.
3. getAllMessages(): This method retrieves all the SMS messages in the
device's inbox or outbox.
4. deleteMessage(): This method deletes an SMS message from the device's
inbox or outbox.
5. registerContentObserver(): This method registers a content observer to
monitor changes to the SMS messages in the device's inbox or outbox.

You might also like