Answer the following questions
1. Enlist
reasons for why use Android OS?
Ans :
There are so many reasons you should
choose the Android platform for mobile application development.
1. Zero/negligible development cost
The development tools like Android SDK, JDK, and Eclipse IDE, etc. are free to download for the android mobile application development. Also, Google charges a small fee of $25, to distribute your mobile app on the Android Market.
2. Open Source
The Android OS is an open-source
platform based on the Linux kernel and multiple open-source libraries. In this
way, developers are free to contribute to or extend the platform as necessary
for building mobile apps which run on Android devices.
3. Multi-Platform Support
In the market, there is a wide range of
hardware devices powered by the Android OS, including many different phones and
tablets. Even the development of android mobile apps can occur on Windows, Mac
OS, or Linux.
4. Multi-Carrier Support
World wide a large number of telecom
carriers like Airtel, Vodafone, Idea Cellular, AT&T Mobility, BSNL, etc.
are supporting Android-powered phones.
5. Open Distribution Model
Android Market place (Google Play
store) has very few restrictions on the content or functionality of an android
app. So the developer can distribute their app through the Google Play store
and as well other distribution channels like Amazon’s app store.
2. Write
short note on: History of Android.
Ans :
The history and versions of android are
interesting to know. The code names of android ranges from A to J currently,
such as Aestro, Blender, Cupcake, Donut, Eclair, Froyo, Gingerbread, Honeycomb,
Ice Cream Sandwitch, Jelly Bean, KitKat and Lollipop. Let's understand the
android history in a sequence.
1) Initially, Andy Rubin founded
Android Incorporation in Palo Alto, California, United States in October, 2003.
2) In 17th August 2005, Google acquired android Incorporation. Since then, it
is in the subsidiary of Google Incorporation.
3) The key employees of Android
Incorporation are Andy Rubin, Rich Miner, Chris White and Nick Sears. 4)
Originally intended for camera but shifted to smart phones later because of low
market for camera only.
5) Android is the nick name of Andy
Rubin given by coworkers because of his love to robots. 6) In 2007, Google
announces the development of android OS.
7) In 2008, HTC launched the first
android mobile.
Version Code
name API Level
1.5 Cupcake 3
1.6 Donut 4
2.1 Eclair 7
2.2 Froyo 8
2.3 Gingerbread 9 and 10
3.1 and 3.3 Honeycomb 12 and 13
4.0 Ice
Cream Sandwitch 15
4.1, 4.2 and 4.3 Jelly Bean 16, 17 and
18
4.4 KitKat 19
5.0 Lollipop 21
6.0 Marshmallow 23
7.0 Nougat 24-25
8.0 Oreo 26-27
3. What
is meant by AVD?
Ans :
1. The Android Virtual Device Manager
allows you to create Android Virtual Devices (AVDs), which you can then run to
emulate a device on your computer. There's an important but subtle distinction
between simulation and emulation.
2. Simulation means that the virtual
device is merely a façade that simulates how an actual physical device might
behave, but does not run the targeted operating system. The iOS development
environment uses simulation, and this is probably a good choice for iOS given
the limited number of devices available for that platform.
3. With emulation, however, your
computer sets aside a block of memory to reproduce the environment found on the
device that the emulator is emulating. Android Studio uses emulation, which
means the Android Virtual Device Manager launches a sandboxed version of the
Linux kernel and the entire Android stack in order to emulate the environment
found on the physical Android device.
4. Although emulation provides a much
more faithful environment on which to test your apps than simulation does,
booting up an AVD can drag into the minutes, depending on the speed of your
computer. The good news is that after your emulator is active in memory, it
remains responsive. Nevertheless, if you have an Android phone or tablet, we
recommend using the physical device to test your apps, rather than using an
AVD.
4. Write
short note on: Android Emulator.
Ans :
1. The Android emulator runs one full
Android system stack, down to the kernel level, including a set of preinstalled
applications (such as the dialer) that you can access from your applications.
2. We can select the version of the
Android system we wish to run the emulator by configuring AVDs and we can also
modify the mobile device skin and key mappings.
3. While launching the emulator at the
runtime, we can use a variety of commands and options to control its behavior.
4. The Android emulator offers dynamic
binary translation of device machine code to the OS and processor architecture
of your development machine.
The android emulator supports many
hardware features likely to be found on mobile devices, including:
1. AN ARMV5 CPU and the corresponding
Memory Managements Unit (MMU).
2.A 16-bit LCD display.
3. One or more keyboards.
5. What
is ListView? How to use it in Android application? Explain with example.
Ans :
Android ListView is a view which groups
several items and display them in vertical scrollable list. The list items are
automatically inserted to the list using an Adapter that pulls content from a
source such as an array or database.
An adapter actually bridges between UI
components and the data source that fill data into UI Component. Adapter holds
the data and send the data to adapter view, the view can takes the data from
adapter view and shows the data on different views like as spinner, list view,
grid view etc.
The ListView and GridView are
subclasses of AdapterView and they can be populated by binding them to an
Adapter, which retrieves data from an external source and creates a View that
represents each data entry.
Android provides several subclasses of
Adapter that are useful for retrieving different kinds of data and building
views for an AdapterView ( i.e. ListView or GridView). The common adapters are
ArrayAdapter,Base Adapter, CursorAdapter, SimpleCursorAdapter,SpinnerAdapter
and WrapperListAdapter. We will see separate examples for both the adapters.
6. Explain
ListFragment with example.
Ans :
Static library support version of the
framework's ListFragment. Used to write apps that run on platforms prior to
Android 3.0. When running on Android 3.0 or above, this implementation is still
used.
Step Description
1 You
will use Android Studio to create an Android application and name it as
SimpleListFragment under a package com.example.tutorialspoint7.myapplication,
with blank Activity.
2 Modify
the string file, which has placed at res/values/string.xml to add new string
constants
3 Create
a layout called list_fragment.xml under the directory res/layout to define your
list fragments. and add fragment tag(<fragment>) to your
activity_main.xml
4 Create
a myListFragment.java, which is placed at java/myListFragment.java and it
contained onCreateView(),onActivityCreated() and OnItemClickListener()
5 Run
the application to launch Android emulator and verify the result of the changes
done in the application.
7. What
is DialogFragment? Explain its uses.
Ans :
DialogFragment is a utility class of
android development that is used to show a Dialog window, Floating on top of an
activity window in an android application. This feature is added on API Level
11 and Deprecated on API Level 28. It has its own lifecycle which makes this
class very useful for dialog box creation. Here is a sample video to understand
what we are going to build in this article and what actually a Dialog Fragment
is-
Methods of DialogFragment
Below methods are given to control the
flow of DialogFragment, with the proper usage of these methods dialog boxes can
be controlled efficiently.
onAttach()
onCreate()
onCreateDialog()
onCreateView()
onViewCreated()
onDestroy()
8. With
the help of example explain spinner.
Ans :
Android Spinner is a view similar to
the dropdown list which is used to select one option from the list of options.
It provides an easy way to select one item from the list of items and it shows
a dropdown list of all values when we click on it. The default value of the
android spinner will be the currently selected value and by using Adapter we
can easily bind the items to the spinner objects. Generally, we populate our
Spinner control with a list of items by using an ArrayAdapter in our Kotlin
file.
Different Attributes for Spinner Widget
android:id Used to specify the id of the view.
android:textAlignment Used to the text alignment in the dropdown
list.
android:background Used to set the background of the view.
android:padding Used to set the padding of the view.
android:visibility Used to set the visibility of the view.
android:gravity Used to specify the gravity of the view like center, top,
bottom, etc
9. Explain
GridView Using adapter with the help of example.
Ans :
A GridView is a type of AdapterView
that displays items in a two-dimensional scrolling grid. Items are inserted
into this grid layout from a database or from an array. The adapter is used for
displaying this data, setAdapter() method is used to join the adapter with
GridView. The main function of the adapter in GridView is to fetch data from a
database or array and insert each piece of data in an appropriate item that
will be displayed in GridView. This is how the GridView structure looks like.
Note that we are going to implement this project using the Java language.
XML Attributes of GridView
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.
10. Explain
ListView Using adapter with the help of example.
Ans :
An adapter actually bridges between UI
components and the data source that fill data into UI Component. Adapter holds
the data and send the data to adapter view, the view can takes the data from
adapter view and shows the data on different views like as spinner, list view,
grid view etc.
The ListView and GridView are
subclasses of AdapterView and they can be populated by binding them to an
Adapter, which retrieves data from an external source and creates a View that
represents each data entry.
Android provides several subclasses of
Adapter that are useful for retrieving different kinds of data and building
views for an AdapterView ( i.e. ListView or GridView). The common adapters are
ArrayAdapter,Base Adapter, CursorAdapter, SimpleCursorAdapter,SpinnerAdapter
and WrapperListAdapter. We will see separate examples for both the adapters.
ListView Attributes
Sr.No Attribute
& Description
1 android:id
This is the ID which uniquely
identifies the layout.
2 android:divider
This is drawable or color to draw
between list items.
3 android:dividerHeight
This specifies height of the divider.
This could be in px, dp, sp, in, or mm.
4 android:entries
Specifies the reference to an array
resource that will populate the ListView.
11. Explain
Photo Gallery Using adapter with the help of example.
Ans :
In Android, Gallery is a view that can
show items in a center locked, horizontal scrolling list, and hence the user
can able to select a view, and then the user selected view will be shown in the
center of the Horizontal list. “N” number of items can be added by using the
Adapter. The adapter is a bridging component between UI component and data
source(It can be an array of items defined in java code or from a database).
The items given in the adapter will be shown in the gallery in the example.
<Gallery
android:id="@+id/languagesGallery"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="100dp"
android:unselectedAlpha="50"
android:spacing="5dp"
android:animationDuration="2000"
android:padding="10dp"
/>
12. Explain
Work Thread with example.
Ans :
When an application is launched in
Android, it creates the primary thread of execution, referred to as the “main”
thread. Most thread is liable for dispatching events to the acceptable
interface widgets also as communicating with components from the Android UI
toolkit. To keep your application responsive, it’s essential to avoid using the
most thread to perform any operation which will find yourself keeping it
blocked.
Android provides some ways of making
and managing threads, and lots of third-party libraries exist that make thread
management tons more pleasant. However, with numerous approaches at hand,
choosing the proper one are often quite confusing. In this article, you’ll
study some common scenarios in Android development where threading becomes essential
and a few simple solutions which will be applied to those scenarios and more.
Threading in Android
In Android, you’ll categorize all
threading components into two basic categories:
Threads that are attached to an
activity/fragment: These threads are tied to the lifecycle of the
activity/fragment and are terminated as soon because the activity/fragment is
destroyed.
Threads that aren’t attached to any
activity/fragment: These threads can still run beyond the lifetime of the
activity/fragment (if any) from which they were spawned.
13. Explain
AsyncTask in detail.
Ans :
Android AsyncTask going to do
background operation on background thread and update on main thread. In android
we cant directly touch background thread to main thread in android development.
asynctask help us to make communication between background thread to main
thread.
Methods of AsyncTask
onPreExecute() − Before doing
background operation we should show something on screen like progressbar or any
animation to user. we can directly comminicate background operation using on
doInBackground() but for the best practice, we should call all asyncTask methods
.
doInBackground(Params) − In this method
we have to do background operation on background thread. Operations in this
method should not touch on any mainthread activities or fragments.
onProgressUpdate(Progress…) − While
doing background operation, if you want to update some information on UI, we
can use this method.
onPostExecute(Result) − In this method
we can update ui of background operation result.
Generic Types in Async Task
TypeOfVarArgParams − It contains
information about what type of params used for execution.
ProgressValue − It contains information
about progress units. While doing background operation we can update
information on ui using onProgressUpdate().
ResultValue −It contains information
about result type.
14. Explain
Broadcast Receiver with example.
Ans :
Broadcast in android is the system-wide
events that can occur when the device starts, when a message is received on the
device or when incoming calls are received, or when a device goes to airplane
mode, etc. Broadcast Receivers are used to respond to these system-wide events.
Broadcast Receivers allow us to register for the system and application events,
and when that event happens, then the register receivers get notified. There
are mainly two types of Broadcast Receivers:
Static Broadcast Receivers: These types
of Receivers are declared in the manifest file and works even if the app is
closed.
Dynamic Broadcast Receivers: These
types of receivers work only if the app is active or minimized.
Creating the Broadcast Receiver:
class
AirplaneModeChangeReceiver:BroadcastReceiver() {
override fun
onReceive(context: Context?, intent: Intent?) {
// logic of the code needs to be written here
}
}
15. Explain
life cycle of Services.
Ans :
The service life cycle consists of the
same four stages at the product life cycle: introduction, growth, maturity and
decline. The characteristics of each stage are the same. The only difference
lies in the strategies that can be used.
I INTRODUCTORY STAGE
A new service or a new form of a
current service is said to be in the introductory stage when it is first
offered. As with goods, many new services never obtain acceptance by customers
and never get past the first stage of the service life cycle. An advantage that
services have over goods is that many new services can be introduced on a small
scale and expanded if acceptance grows. This small scale introduction reduces
the financial risk associated with the introduction, making failure less
costly.
II GROWTH STAGE
During the growth stage, the industry
is growing rapidly. Most firms offering the new service are seeing a positive
cash flow.
For eg: a patient can learn about the
incubation period for chicken pox by either talking to a nurse or dialing into
a vast library of prerecorded tapes.
III MATURITY STAGE
During the maturity stage, industry
sales level off. Competition becomes very intense since the only way a firm can
gain the market share or increase sales is to take them away from a competitor
At this stage in the service life cycle, consumers see very few distinguishable
characteristics among the various firms in a service industry.
IV DECLINE STAGE
During the decline stage, industry
sales decline. This sales drop is often due to a new technology that has been
developed. For eg, typewriter repair services declined bcoz typewriters were
largely replaced by computers which resulted in a need for a computer service
technicians and computer programmers.
16. Explain
Notification with example.
Ans :
Notification is a kind of message,
alert, or status of an application (probably running in the background) that is
visible or available in the Android’s UI elements. This application could be
running in the background but not in use by the user. The purpose of a
notification is to notify the user about a process that was initiated in the
application either by the user or the system. This article could help someone
who’s trying hard to create a notification for developmental purposes.
Notifications could be of various
formats and designs depending upon the developer. In General, one must have
witnessed these four types of notifications:
1. Status Bar Notification (appears in
the same layout as the current time, battery percentage)
2. Notification drawer Notification
(appears in the drop-down menu)
3. Heads-Up Notification (appears on
the overlay screen, ex: Whatsapp notification, OTP messages)
4. Lock-Screen Notification (I guess
you know it)
17. How
to create database in SQLite? Explain with example.
Ans :
In SQLite, sqlite3 command is used to
create a new SQLite database. You do not need to have any special privilege to
create a database.
Syntax Following is the basic syntax of
sqlite3 command to create a database: −
$sqlite3 DatabaseName.db
Always, database name should be unique
within the RDBMS.
Example If you want to create a new
database <testDB.db>, then SQLITE3 statement would be as follows −
$sqlite3 testDB.db
SQLite version 3.7.15.2 2013-01-09
11:53:05
Enter ".help" for instructions
Enter SQL statements terminated with a
";"
sqlite>
The above command will create a file
testDB.db in the current directory. This file will be used as database by
SQLite engine. If you have noticed while creating database, sqlite3 command
will provide a sqlite> prompt after creating a database file successfully.
Once a database is created, you can
verify it in the list of databases using the following SQLite .databases
command.
sqlite>.databases
seq name file
--- --------------- ----------------------
0 main /home/sqlite/testDB.db
You will use SQLite .quit command to
come out of the sqlite prompt as follows −
sqlite>.quit
$
18. What
is cursor in SQLite?
Ans :
Cursor is a Temporary Memory or
Temporary Work Station. It is Allocated by Database Server at the Time of
Performing DML(Data Manipulation Language) operations on Table by User. Cursors
are used to store Database Tables. There are 2 types of Cursors: Implicit
Cursors, and Explicit Cursors. These are explained as following below.
Implicit Cursors:
Implicit Cursors are also known as
Default Cursors of SQL SERVER. These Cursors are allocated by SQL SERVER when
the user performs DML operations.
Explicit Cursors :
Explicit Cursors are Created by Users
whenever the user requires them. Explicit Cursors are used for Fetching data
from Table in Row-By-Row Manner.
19. With
the help of example describe getting location data.
Ans :
Also known as geographic information or
geospatial data, location data refers to information related to objects or
elements present in a geographic space or horizon. There are two basic types of
location data: vector data and raster data.
Vector: This form uses points, lines,
and polygons to represent features such as cities, roads, mountains, and bodies
of water that are mapped and stored in geographic information systems (GIS).
Raster: This form uses cells to
represent spatial features. An example would be remote satellite data.
Examples of data visualizations that
use location data
Technology advances are improving our
ability to capture more location data every day. While previously only plotted
on a physical map, the list of map types grew as this type of data and different
technology (i.e. mobile devices, location-based services, etc.) evolved.
20. Explain
the term displaying Google map in detail.
Ans :
Android provides facility to integrate
Google map in our application. Google map displays your current location, navigate
location direction, search location etc. We can also customize Google map
according to our requirement.
Types of Google Maps
There are four different types of
Google maps, as well as an optional to no map at all. Each of them gives
different view on map. These maps are as follow:
Normal: This type of map displays
typical road map, natural features like river and some features build by
humans.
Hybrid: This type of map displays
satellite photograph data with typical road maps. It also displays road and
feature labels.
Satellite: Satellite type displays
satellite photograph data, but doesn't display road and feature labels.
Terrain: This type displays
photographic data. This includes colors, contour lines and labels and
perspective shading.
None: This type displays an empty grid
with no tiles loaded.
Syntax of different types of map
googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
googleMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN);
0 Comments