Android All Questions Combined
Android All Questions Combined
Pago OL
Mobtte PPLicatioON o
ci Coaming QP
C Bncductivity aps
cli) ifeshylaamd emtortamment ap
uls inckudls mobil CammRXCe a}'s
oHher alp Pchase
Lysed goods mline Such oas
Amam 0 eßau avel apps hat hlP
Date
C8Bookhg toes
a oavelen in mamu iays
amo ichets fmding- thein_LsayHrogh etc.
maps and gealecatian avel dra amc
mo utilitu a dLch as haalth afs
baHCode Scamnets.
ChanacteáifcA
inctttimgs Coa
Lde Chm do mtorms
dalelefmant an aP mobtle, bu Lunles
noie ~hings altan lutih 4he meds amd goa
enobab huetiig
moYe than hulping Many paople hale Shoxt
OtAmtim Sams amd I illmaa uowh
aPp diffCulttp maiaate dham the uA esLd
Veu tast
unable to acco he Sngomau m
Auicau Mauigatm amd 10
Ambiaurty imhove
h de experdemca
ped n hts era mo gn Utacs Lsaiting
atcular4, Leham all they have o
Jaca at loading Symbo m 4h
Scritn. 1hid dufe of Sitaatin ACHO
Dato L
Pagel
1 Applications
Android Framework
Androld Ruitime
4Piattorm Libraries
5 Linux Kenel
Location Service
NFC Service
Activity Manager Package Manager
View System
Windows Manager Notification Manager oen
ndrol Kuntime
Core Libraries
Dalvik Virtual Machine ygote Androld Debug Bridge
Pattorm ibraties
SGL
Openal Graphics
MediaFramework
Freetype
SSL sQLite Surface Manager
n i Xetnel
Applications
of the androld architecture is Applications, The native and third-party applications
The top layer
ke contacts, email, music, gallery, clock, games, etc: Wwhatever we will build those will be installed
The application layer runs within the Android run time using the classes and services made
Application Framework
The Application Framework provides the classes used to create Android applications. It also
the user intertace ano
provides a generic abstraction for hardware accesS
and manages
o n resources lt basically provides the services
s s and
make that class through which we can createparucu
ular
helpful for the Application creation
caon framework includes services like
telephony service, location services, notihicatio
ron c e , view
system, etc which we can use for
fequirerments application development as per oul
Android Runtime
naroid Runtime environment is an
important part of Android rather than an internal
scomponents libraries and the Dalvik virtual machine. The Android part
lilke core and
gne that powers our applications along with the libraries and it forms the basis
run time
Ppication framework
1of te
Daivik Virtual
Machine (DVM) is a
register-based virtual machine
w.tt 15 Specially designed and optimized like Java Virtual Machine
nstances for android to ensure that a device can run
efficientiy. it reles on
threading and low-level memory iu pie
the Linux kermel tor
management
Thecore libraries in android
runtime will enable us
standard JAVA
programming language.
to
implement android applications Using
Platform Libraries
The Platform
Libraries includes various C/C++
SSL libe, Graphics, core libraries and
SQuite, Webkit, Media, Surface Java-based libraries such as
Android development Manger, OpenaL, etc. to provide
Ihe
tor support
following are the
summary details of some core
development android libraries
available for android
APL Juel -1
feotunes- alllooin ppltaliom olownloads
ndoid Hake the mdket applbiecaluon
and upolate thouh
Camea duppovt Guaildpplbtoluom
raa mchonizaduon with
calende Hops ynthoni alon
GooqLe cohtacts ,
mpo
Media Ployes mablum9 mamagment,
,
to up-load
ALi
utoAotaten epton
moted creem troui on.
One touch -a Ctess a conlacd carolTom tal og
Duemt
dncbroid 6 (Domut)-
On tpt 1S, d009 nduid 6- dubbed Donut -uw
neleasedl, based on nux ktsnel &6: 1.
APL Level
feotuunes
Voice amd texi eiby &eorth on wtb
incudle their conlent
dbilhy ov oluelspers
6e0rch Auli
in
mose
Cammesa amd cam3t CoTde)
alleny
Prlegated
peech mthesi3 mgine
Hull- inguol
ulect uuldiple phots to
lbility oust6
delchon and comesa appbcatoy
Spee d improuement
in
sea2 ching
d o i d A.o (Ecdaiv) LOas
. 0 9Dk
the dndsuoid
Otobey &1, Avo9,
on kemel 6.27
inut
l2aseo based om
AfL
feabwes
xpamded decount ymt
Buuctooth -1 uppost and alet o cal
'bit t tap a (orttacts phole
HS T ommail the peaon
all sawed SMS
and HHS Hessages,
Abiliy to dtach
delete th oldest
oth dhe added abilby to
messages în a tonusatDm
Neuo camea eatvre lash, zom, >cene MOoledh
fetah ed brouáe uL oith bok mastk thoumbnais
Improued oqle Haps 1.9
&uppost for MOvre stem e s and aesalutions
Addihon b ve oallpapeha8.
Feate
&peec Am.bn nd porfooytam ce 6ptumuaouon
duleraition o hyome's 6 JauaScript Imaine
the BrouOsel applbcoton
Device He oging
ppost o dndboiod cloud o
6uice
US8 ethei nq and -hot pot wnduonalrty
oues a HBale netzsavk
optiomte dis able data access
Opdaded Havket applicatuom
Ouick &uod-ching biluwum ulti ple teybot yd Janguayes
amd thuh dictonaie
uumeic md allbhamum@uc 1aA LDrds
Sppot fov
to expamdable
Sppost tor installinq opelcalims
memor
AclobeLash dupot
UehsLOn2-91
Aeloase date3ept 91, o10
anmd pefommamce
u xes daeuty updaTes
improuememta
Josion & 9 2 -
Reloase data Son 81, 9o1)
ialues that
Hin bug ixes inctuding 3H3 Aotding
e u us
akectpd the
One
Version8.1-
ndoid 31 Homeytomb
Reloase dade Hay 1o,doll
APA Leal 1 =
U hein emevtls
Comnedivty fos U3B accessovies
Resiaable Home cveen uodgebs
ppot fo oystíck amd gamepods.
'Bupatoflic audio playbok
+Ban peomon ce u lock
ondroiol 3.8 omy Comb
AP 13
Reloose dote -3uly IS, 8o1)
Versi on 3.0
Smpmuec horduoahe uppot
neneased abiity pcauos tu o (cessles
T
D e dP&ppoit umduom
Vesiom 38 Reloast dale 8ept 20, 2o1
Sug amd unoY A0Cunity, stability
Update groqle boks.
'n BrouwseT.
Smprouerote Ndabe Plash Juppost
Vtrsion 8.0
Kelense date Sept 9, 8ol
improutmemlsfo
e s amd othes munoY
Hoto ola Xbom 1.
sio 28.4 Releose date- Oec 1S, dolf
o Y 39 amd u9 table
Verdion 3 86- Relense date feb I9, ol2
when u
fed dlata eonnedivity dasues coming
Qiplame HOde
4.
Android 4.0 Ice Cveam Samduoich
Release date - Dct 19, 2o11
based on Bnux kemel 3.0:
&thlaut vesion l a l y ppost Adobe
ugtm flash plaes
Hajor Aekinemenils wth ne Roboo font amuly
tbttons nom dhdnid0x ae noo on phDnes
asies to ceate older btth daag And drop dtyfe
Pineh t 2601m uwmctionally in calendlor
lmprouAd emrby Lmidtuom On keyo o0 d.
tO Divect
etler voice ivteraluon
Built ?n phob llos
Vesi On 4.0, 4:0 x ed mino baga)
&nd roid 4 03
Tce Coeam Sanduoich
A PL 15S
Release oate - oec 16,Aol
Veasi0 4.0:3
0uerous bugtx eA and api uadons
Improvement to graphs and dala beseunchonality
Oeuo comer a oPpbtouon nhonCtrg Uideo
oup M aging uppoit
Vesion y Kelcase olaile Nov 87, 8o)la
FiLed
baug peeple appbcatuon
in th
Vesion 9-9 - Roleose date - feb lI, 3o13
ixed blue oth Ouudio
bheamin itons.
and uetooth
bvpresingths wdi
ndoid 4:3 Tell Beon
AP4 18
Release date July 19, 2o18
Bluetooth Du ener9yuprt
Notit oiurpot
K Aesolution Appot
Kestnicted attes HOdeo neo ser preiles
AP 19
Release elate 0ct 31,8613
Releshed lesa ce oth wte leMe yd
Veidied bot
Clock n Jonger how bold hound
Oneless pinding capabily
Oodtut tnrayed bl&sten
Nau 4.4 KHkat oith wearable ectemsions
Keleare olate -Jotne , oly
Vesion .4 W
Bndo1Cl
deD platyomn to
3ntundnelease o the
maot uodtthes
VeYsion y.4
Keloac. odlate Sept 6, ol
U1 bpdates o gooale aps nayi gat on alo omd.
Versi on u.y Lo
Kelease d ote - Oct 81, 9o14
Projet 1wble
, the bggest chargt
Pretut- in picrse Aupt
-
Adoptiv îons.
ADeicoluon improue Nends
Syalum d e Adat?ll rameudonk
alti- di solay pot
Gpog e play fole
droid 8 Dreo
AP
34 is the 16 pinoy Aelease o the dndooid D
Vexslom 81- Rele ase dale Dec S 9ol
eus al Nehuooska ART
Jhoved Hemoy AT
Oallpape tolbrS T
urtabil Toneuoovk wpdates
loost Heysages a noo cdhite
dotaie h t and dok bhemes
*Ooviaduon loutow ol when not in use
ndroid 9 Pie
Release dote -Rug oll
t he ajos Aelease
NeLs wtr inilefoce ta the quick sRtng Mem
Clodk hs Hovec ds the J ntitom bat
Rounded eomes atnoss the u
'eud ransiiovs avsLOYtchi'ng betujeem aPPA adivihieg
Sppovt o usplay Cuou
Redesigmed velume liden
mdbuoid olashboo-rd
CalAecovdinq plionsullsabled.
tndroid o
AP 89
HLOOY elease. he 5table vesi Om uas
eleased On
Sept 8,2o19.
Revomped &teem esut nauig auom th
aPpspmclose ariuai on new
Sco ped oraqe neshictons
G-ted occess do nom- A0s7ttable olauCe 1dlemu
Getoy ppo»t lov blomelic QuthemiicaLion tn Gpps
On oluce
to he
nd-id RuriMe (AR) HOdule added
coTe as cOmponemu via aogle Play
upoladale
Bold exl neysCale
PRvau clashbord.
&ndhoid 18
AOL 31
pole amnounted nolnoid 19, on inloio heeabe
d o i d 1 tncauding mprouemeris spet (
tololable phonos toblebs ete
Kelease dlale BA
sts
Oative duppost ov taking srelling bereemsh
Halei alu Y ou
Oidget Ue update wih nes
desigm lamgunge
Plaosm
.doy
Kao heesh to the eppaing duysle
Andoid 13
dndnoid 18L,
Ater the duttessul nelease o
ndroid 1 will be eleased
(e) Checkbox.
TextView Attributes
Following are the important attributes related to TextView control. You can check Android
official documentation for complete list of attributes and related methods which you can use to
change these attributes are run time.
1 android:id
2 android:capitalize
If set, specifies that this TextView has a textual input method and should automatically
capitalize what the user types.
3 android:cursorVisible
4 android:editable
6 android:gravity
Specifies how to align the text by the view's x- and/or y-axis when the text is smaller than
the view.
7 android:hint
8 android:inputType
The type of data being placed in a text field. Phone, Date, Time, Number, Password etc.
9 android:maxHeight
10 android:maxWidth
11 android:minHeight
12 android:minWidth
13 android:password
Whether the characters of the field are displayed as password dots instead of themselves.
Possible value either "true" or "false".
14 android:phoneNumber
If set, specifies that this TextView has a phone number input method. Possible value either
"true" or "false".
15 android:text
Text to display.
16 android:textAllCaps
Present the text in ALL CAPS. Possible value either "true" or "false".
17 android:textColor
Text color. May be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb".
18 android:textColorHighlight
19 android:textColorHint
Color of the hint text. May be a color value, in the form of "#rgb", "#argb", "#rrggbb", or
"#aarrggbb".
20 android:textIsSelectable
Indicates that the content of a non-editable text can be selected. Possible value either
"true" or "false".
21 android:textSize
Size of the text. Recommended dimension type for text is "sp" for scaled-pixels (example:
15sp).
(b).Edit Text
EditText Attributes
Following are the important attributes related to EditText control. You can check Android
official documentation for complete list of attributes and related methods which you can use to
change these attributes are run time.
If set, specifies that this TextView has a textual input method and automatically corrects
some common spelling errors.
2 android:drawableBottom
3 android:drawableRight
4 android:editable
5 android:text
1 android:background
2 android:contentDescription
3 android:id
This is the name of the method in this View's context to invoke when the view is clicked.
5 android:visibility
(c). Button
In Android applications, a Button is a user interface that is used to perform some action when
clicked or tapped. It is a very common widget in Android and developers often use it.
A Button is a Push-button which can be pressed, or clicked, by the user to perform an action.
Button Attributes
Following are the important attributes related to Button control. You can check Android official
documentation for complete list of attributes and related methods which you can use to
change these attributes are run time.
1 android:autoText
If set, specifies that this TextView has a textual input method and automatically corrects
some common spelling errors.
2 android:drawableBottom
3 android:drawableRight
5 android:text
Attribute Description
1 android:background
2 android:contentDescription
3 android:id
4 android:onClick
This is the name of the method in this View's context to invoke when the view is
clicked.
5 android:visibility
Programmatically, isChecked() method is used to check the current state of the toggle button.
This method returns a boolean value. If a toggle button is ON, this returns true otherwise it
returns false. Below is the example in which toggle button is used.
ToggleButton Attributes
1 android:disabledAlpha
2 android:textOff
3 android:textOn
1 android:autoText
If set, specifies that this TextView has a textual input method and automatically corrects
some common spelling errors.
2 android:drawableBottom
This is the drawable to be drawn below the text.
3 android:drawableRight
4 android:editable
5 android:text
1 android:background
2 android:contentDescription
3 android:id
4 android:onClick
This is the name of the method in this View's context to invoke when the view is clicked.
5 android:visibility
Android CheckBox is a type of two state button either checked or unchecked. There can be a
lot of usage of checkboxes. For example, it can be used to know the hobby of the user,
activate/deactivate the specific action etc. Android CheckBox class is the subclass of
CompoundButton class.
CheckBox Attributes
android:autoText
1 If set, specifies that this TextView has a textual input method and automatically corrects
some common spelling errors.
android:drawableBottom
2
This is the drawable to be drawn below the text.
android:drawableRight
3
This is the drawable to be drawn to the right of the text.
android:editable
4
If set, specifies that this TextView has an input method.
android:background
1
This is a drawable to use as the background.
android:contentDescription
2
This defines text that briefly describes content of the view.
android:id
3
This supplies an identifier name for this view.
android:onClick
4
This is the name of the method in this View's context to invoke when the view is clicked.
android:visibility
5
This controls the initial visibility of the view.
Why do we need the list-based widgets. Explain
the listView and Spinner with suitable example ?
ListView :-
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.
List View
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).
ListView Attributes
Following are the important attributes specific to GridView −
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.
5 android:footerDividersEnabled
When set to false, the ListView will not draw the
divider before each footer view. The default value is
true.
6 android:headerDividersEnabled
When set to false, the ListView will not draw the
divider after each header view. The default value is
true.
ArrayAdapter
You can use this adapter when your data source is an array. By
default, ArrayAdapter creates a view for each array item by
calling toString() on each item and placing the contents in
a TextView. Consider you have an array of strings you want to
display in a ListView, initialize a new ArrayAdapter using a
constructor to specify the layout for each string and the string
array −
ArrayAdapter adapter = new
ArrayAdapter<String>(this,R.layout.ListView,Str
ingArray);
Here are arguments for this constructor −
First argument this is the application context. Most of the
case, keep it this.
Second argument will be layout defined in XML file and
having TextView for each string in the array.
Final argument is an array of strings which will be
populated in the text view.
Once you have array adapter created, then simply
call setAdapter() on your ListView object as follows −
ListView listView = (ListView)
findViewById(R.id.listview);
listView.setAdapter(adapter);
You will define your list view under res/layout directory in an
XML file. For our example we are going to using
activity_main.xml file.
Example
Step Description
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.ArrayAdapter;
import android.widget.ListView;
@Override
protected void onCreate(Bundle
savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".ListActivity" >
<ListView
android:id="@+id/mobile_list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
Following will be the content of res/values/strings.xml to
define two new constants-
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">ListDisplay</string>
<string
name="action_settings">Settings</string>
</resources>
Following will be the content
of res/layout/activity_listview.xml file −
<?xml version="1.0" encoding="utf-8"?>
<!-- Single List Item Design -->
<TextView
xmlns:android="http://schemas.android.com/apk/r
es/android"
android:id="@+id/label"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dip"
android:textSize="16dip"
android:textStyle="bold" >
</TextView>
Spinner :-
Spinner allows you to select an item from a drop down menu
For example. When you are using Gmail application you would
get drop down menu as shown below, you need to select an
item from a drop down menu.
Example
This example demonstrates the category of computers, you
need to select a category from the category.
To experiment with this example, you need to run this on an
actual device on after developing the application according to
the steps below.
Steps Description
// Spinner element
Spinner spinner = (Spinner)
findViewById(R.id.spinner);
dataAdapter.setDropDownViewResource(android.R.l
ayout.simple_spinner_dropdown_item);
@Override
public void onItemSelected(AdapterView<?>
parent, View view, int position, long id) {
// On selecting a spinner item
String item =
parent.getItemAtPosition(position).toString();
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:text="Category:"
android:layout_marginBottom="5dp"/>
<Spinner
android:id="@+id/spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:prompt="@string/spinner_title"/>
</LinearLayout>
Modify the res/values/string.xml to the following
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string
name="app_name">AndroidSpinnerExample</string>
</resources>
This is the default AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/r
es/android"
package="com.example.spinner" >
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.spinner.AndroidSpinne
rExampleActivity"
android:label="@string/app_name" >
<intent-filter>
<action
android:name="android.intent.action.MAIN" />
<category
android:name="android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
</application>
</manifest>
Date [I][I J[IJ
k=======================-= I I e Pagel
_ _fl:J
- (~tJ'.JL_u.Ji!LL..M-;F~_L....:....~~---#;~ ------LJ:)L_ atsi 11.nw _u;_n t,.1 c
ect
t-
JJ
II
a
C 111£P ft
Date [I]mm
Page[ 2-. I CJ
HecoJ v ew
An
Ct.
LJ ~ed
7
_ _(y:\ _ _ __,_
Ct"'-'(. v:..i_.
_,_fJ,'__,, L. +:J
_~ - _w-'-f_,_
¼"-' --- -~d~9r...u.ro
..!-!;e__~ c erl lllU
r - - -- ~ 1._ -~ ~v-~P_ ___;~~~~~-~e~
_,µ91-n-!Jg I
od AJ-rv ffJ
,Cfrp~
0-W!ll (JJt' ,M.M-1 1N t '-{ tkn CPt 6n Ch c~llt eo d)-
-..
' IJ,L_
-1.1...,;...,i1u. _u6!.(._e _ _CfJt/
~ J..L.Ced
J,-- cvlJ -)_ __µlM~,.dcz..,,1:L____
-- '- .>c,. ..c...~
-=-
4 I\...L.IC
-""
:l"--=
cP~ t.<,..;,,'tr....!.. efl-R.
'-=--
--1....... 2?-=I_;
we Lu,Jy_j.Je
- - - U - - -- ---'-1',- - -
(_).Jc. .~u r r , lt, ('
...,
'f,;,,. ,. ,
i/1 /
V ),.-
/, ,,... (
'" I
- 1 1 ,r,
/ 1J
I
~ r\ ,, 4~ u r J, 1 i ~ tjl ~ . b1~ .1 f
O> trt ·, rJ) I·
1 ~ ~rJ
vvi d-hod.
-,., ---- - - - - - - -
fa pau
~--=-- ~_,_,_ __._- -~ """" _ _ _
,1,J .Ju f _ _ __
L..____:l:.....:::__:_
/4_R.__f1CL
- - - U - - - --'-"-1<y---
eJ/
-
_-H-----'-£.=6,.,~ ------'...J,c:._,_,_. .___ ~~_ h
_ ±u
tfll?_ - _!,,:J _ A_d;-!.o"l 12cL9f_ ol11.=-
=- - ~ -
- ~ ~ -- ~....r:___a__~'---'- -'-'~ · v; ~- -.---- - - - - - - - - - - - -- - -
Pagel ")
0
) ~ t CtvtCJlg I -/-L ~ f ,L,oph. - -~ -f - - - - - -
Q_/_.lrJ)~µ J~ - Jht:4-tLLf_- ~ -
--
Kt :j__ _/ cLalJ:lzj,'e2 _
L-v 111-etTi_ u R..I _
- - ..LJJ r#-.
_ __
~ _ __ 4-Lk_d_u_ __ {,& rjo tf _ _ _ _ /
_M d -------- -- --
fragment ia Added
OnAtach)
onCueate()
OnCHeatrieu)
aT Acti ty Cteated(
onStart)
onResumec)
hagment is Destroy t
Jara:fragmentManago gmentf(anagu =
tragment7ansq eton tr anaachon =
fragm entManaguu. begi
fsansacton AttRe cord eniny Alloned77ansaction ();
o ansaction . (tut);
Heplatt CR:idfr@gment -(ontarm, EXampletrag
tansachon. Commit (); ment clasw , n
l);
Jn this xample, Q neuu
Instanu o
theragment 1f 9ny that Cuenty Xamplefragment Hepla ces
tn the
lay out (ontaimou
identified by Rid fagment Cuntainv
By delault,
-
the ch ang a
made in a
ragment1rqm4a tti on Qe not added to
back 3tac/e.
sare thase changs, you (an lall
addTo Beck Stac/e C) on the
hagment77ansactron.
Location-Based Services
Mobile phones use several related methods, alone and in combination, to
determine where they are:
Cell ID
Whether you’re actually talking on the phone or not, as long as it’s powered
up, your mobile phone carries on a constant conversation with nearby cell
towers. It has to do this to be able to respond when someone calls you, so
every few seconds it “pings” the cell tower it was using last to tell it that it’s
still in range and to note network parameters such as the current time, the
current signal strength (uplink and downlink), and so on.
Triangulation
Most of the time your mobile phone is in range of more than one cell tower. In
2G and later mobile technologies, the cell tower has the ability to tell what
direction your signal is coming from. If there are two or three towers that can
see your phone, together they can triangulate on your phone’s location. With
some operators, your phone then has the ability to query the network to find
out where it’s been located. This sounds a little backward, but it can be very
accurate, and it doesn’t depend on any extra hardware on the mobile phone.
GPS
GPS radios and processors are fairly inexpensive, but still, an increase of even
$10 in the bill-of-materials cost of a mobile phone is considerable.
There have been great strides in reducing the power required by GPS radios
and processors, but they still suck battery power. Most phones that include
GPS also have a feature that lets the user turn it on and off. If your application
depends on GPS accuracy, it’s good to remember that your application might
have to check to see whether the GPS device is turned on, and notify the user
if it isn’t.
Unreliable availability
Nothing “always works,” but GPS in particular depends on your mobile device
being able to see the satellites currently overhead. If you’re in the basement of
a high-rise building, surrounded by steel-reinforced concrete, you probably
aren’t going to be able to use GPS.
It’s reasonable to expect that all Android phones will include one or all of these
location finding methods. Most recent Android phones, in particular, can use
them all. So now we’ll proceed to techniques for using the location capabilities.
One of the applications that comes with Android is the Google Maps
application itself. If it’s appropriate, you can start Google Maps from your
application the same way you start any other Activity:
1. Create an Intent (new Intent(String action, Uri uri)) that says you need to
display a map. The parameters are:
• An action, for which you must specify ACTION_VIEW.
• A Uri, for which you should specify one of the following URI
schemes, substituting your data:
—geo:latitude, longitude
— geo: latitude , longitude ?z= zoom — geo:0,0?q
my_street_address
— geo:0,0?q business_near_city
2. Call startActivity(Intent intent), using the intent you just created.
addCircle(CircleOptions options)
1
This method add a circle to the map
addPolygon(PolygonOptions options)
2
This method add a polygon to the map
addTileOverlay(TileOverlayOptions options)
3
This method add tile overlay to the map
animateCamera(CameraUpdate update)
4
This method Moves the map according to the update with an animation
clear()
5
This method removes everything from the map.
getMyLocation()
6
This method returns the currently displayed user location.
moveCamera(CameraUpdate update)
7
This method repositions the camera according to the instructions defined in
the update
setTrafficEnabled(boolean enabled)
8
This method Toggles the traffic layer on or off.
snapshot(GoogleMap.SnapshotReadyCallback callback)
9
This method Takes a snapshot of the map
stopAnimation()
10
This method stops the camera animation if there is one in progress
The maps activity file is the main activity for the app, and contains the code to
manage and display the map. By default, the file that defines the activity is
named MapsActivity.java or if you set Kotlin as the language for your
app, MapsActivity.kt.
The main elements of the maps activity:
• The SupportMapFragment object manages the life cycle of the map and
is the parent element of the app's UI.
• The GoogleMap object provides access to the map data and view. This is
the main class of the Maps SDK for Android. The Map Objects guide
describes the SupportMapFragment and GoogleMap objects in more
detail.
• The moveCamera function centers the map at the LatLng coordinates for
Sydney Australia. The first settings to configure when adding a map are
usually the map location and camera settings; such as viewing angle,
map orientation, and zoom level. See the Camera and View guide for
details.
• The addMarker function adds a marker to the coordinates for Sydney.
See the Markers guide for details.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is
ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment)
getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the
camera. In this case,
* we just add a marker near Sydney, Australia.
*
* If Google Play services is not installed on the device, the user will be
prompted to install
* it inside the SupportMapFragment. This method will only be triggered
once the user has
* installed Google Play services and returned to the app.
*/
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
dependencies {
implementation 'com.google.android.gms:play-services-maps:18.0.2'
// ...
}
• tools: context sets the default activity of the fragment to Maps Activity,
which is defined in the maps activity file.
• android: name sets the class name of the fragment to
SupportMapFragment, which is the fragment type used in the maps
activity file.
The XML layout file contains the following code:
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/map"
tools:context=".MapsActivity"
android:name="com.google.android.gms.maps.SupportMapFragment" />
Video Playback
Video playback, unlike audio playback, can use only the
MediaPlayer. There is no video equivalent to AudioTrack.
Video uses the MediaPlayer similarly to audio files, but you
must additionally specify a view (called a surface) on which
the video can be displayed. Android offers a convenient
control that includes its own surface: the VideoView view. An
example of its use follows. It includes the addition of an
optional controller that lets the user control the playback
through a simple interface that includes buttons to start,
stop, and pause the playback, as well as a seek bar to skip
forward or back within the video’s playback progress:
// create the view (in this case it is already included in the
layout resource)
VideoView videoview = (VideoView)
findViewById(R.id.videoview);
videoview.setKeepScreenOn(true);
// used if streaming
if (videouri != null) videoview.setVideoURI(videouri);
// absolute path if it is a file
else videoview.setVideoPath(videopath);
// let's add a media control so we can control the playback
mediacontroller = new MediaController(this);
mediacontroller.setAnchorView(videoview);
videoview.setMediaController(mediacontroller);
if (videoview.canSeekForward())
videoview.seekTo(videoview.getDuration()/2);
// start the playback
videoview.start();
Page No. .
Type- Hard a t
escupion-Mcasune Jh aceednation o
in l 2 that is ahplied to dance o
al ntce hysial axcsxy1) in dina
fhekora havit
ComoCes- Motron dcection Cabuke, HL c)
2 pe- anbitnt Jeperatunc
Sype- Hardusane
Desciphou Mcanes Jhe ambians
menatunr in C).
Signature of the Candidate
Page No.
3 ypC- nraity
lype-Sottuoane o Hordioar
Dsiphion Mcasuncs J toner 6 naity in
m2 a t i sahped to a deice
On all
al n t t hyial aru 341Z)
ommoh Cse Motio Dcecion (4hake, lH cte)
ype ny
1pclardiwant
Décph0n Mtasun Jhs deice a t d
otahon inrad/4 arowd cach o
onte y al onyx, 4,z
omnon yu Kotahion dctrcti (apin, twrn,ch)
Yp Mardsarr
Disouphisn : Meaurey h ambiend Ligt doel
iurinatim) is P
Comon u ontaolling Sences Bighkncs
6ype- Untay Aceelerationm
Ype Sant on Ha-duwane
Dueiphou Mcaswt acc acceleratim force in
4 hat i applicd to a donu n all
phyd)eal aris xgz) Crclui
rghaity
ac eliathon
Usu: Monifoun aog a
yt
x-aris. J
Signature of the Candidate
Page No.
Roll No. (in figures). Code of Paper:
81ye: Oicntah on
14pe Satdan
Dueipho-Mess nes odeghee sF wtati
S a duice arou
all nec ydi cal arts (yz)
As e APf l e l 3, you Can ablain
in clihah matnix and rotation matM
a a duice by uI 9haity Sency
Oaanehc
Ccnjunho oif t RotahnMatiaC) hod.
O ' Deteinr dcmce sho
p-Harrduant
TDesovbhm- Measwr ambent ai prusmc
Pa bay
se MonfoUn ain Cisure Chores
l lo e - Hardioane
Broximi
Deserpthio Mcasunt x i
pxi mity , an
objcet CMnlahi viuJcen
Signature of the Candidate
Page No.
13 pe-epenahunt.
1ype Hard ioane.
Desoi bhi0H- Mcauhr he ttnpeatune sdice
iC) The serson inplementati0 varu
acnos deice & y Awans a aeplaceA
oi ypeAmbient Tepunatwne ese
in AfT e 4
Csu:Mowtoing tenperatune
Sen san ad in Andhip APbt
Androi d - powe oleics hae built-in
Jat misnt hofh , ountah 0
Cwnohhental Codiion.
hse sson t Capable troidin
Coifh i g do0uon ad a cuurnady
and ant
kuliyou antto
Senson Mlanag e
(Suyon aManat Contontget SystoSenvice (ConkedSCNseR
SCRVICE
Il gcktis The defanCf a
Ceelezomctey
Scso
accelmhg get Defrull Sensoy (Senso:1yrE-
ACCELEOMETER);
Igetia h ALs attclo mutcs
i s KSenje7 lisl:g e t SensoyisSen
TYE Ac CELC ROME TË R_
yougot
achall nabl fen andstart gebbin theis
dsa by ntgisnig skney agaiut t a
ssou.
Sense bvenfLiskaenn Sensontent Listenc(O
Ovevnidt
bubic void mACCura eyChanged (Sensere otndo,
altunacy
O v i de
public void drwacy_Charsederyo ensoh,
m
Intaltunaty) t)x
bubcvoid on Séyan Ched (Seantvent tved)1
e g i s i s a Liseae
negiten istegey (Listeney, dehuo», Senso
.
numbers zero through 1023. Because port numbers are 16-bit values, there are
65,536 choices. However, they are broken into the groups shown here:
0 to 1023
1024 to 49151
49152 to 65536
Well-known port numbers Registered ports Dynamic or private ports Because you
are likely to be doing this project on a local area network using unroutable IP
addresses, the port choice isn’t critical. For convenience sake, the server-side
source code for this experiment is listed here:
import java.io.*;
import java.net.*;
import java.util.*;
public class SimpleJavaServer {
public static final int PORT=8888;
public static void main(String args[]){
new SimpleJavaServer().doIt();
}
public void doIt(){
String received="";
try{ ServerSocket ss = new ServerSocket( PORT );
while( true ){ Socket sock = ss.accept();
BufferedReader in = new BufferedReader(new InputStreamReader(
sock.getInputStream() ) ); received=in.readLine();
System.out.println(received);
OutputStreamWriter out = new OutputStreamWriter( sock.getOutputStream() );
BufferedWriter bw=new BufferedWriter(out);
bw.write(received +" received by server \n"); bw.flush(); }
}
catch( Exception e ){ e.printStackTrace();
}}}
On the client side, there are some preliminary steps we need to take before
getting into code. First, we have to be sure the device ’s networking capability is
available to the
@SuppressLint("SetTextI18n")
public class MainActivity extends AppCompatActivity {
Thread Thread1 = null;
EditText etIP, etPort;
TextView tvMessages;
EditText etMessage;
Button btnSend;
String SERVER_IP;
int SERVER_PORT;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
etIP = findViewById(R.id.etIP);
etPort = findViewById(R.id.etPort);
tvMessages = findViewById(R.id.tvMessages);
etMessage = findViewById(R.id.etMessage);
btnSend = findViewById(R.id.btnSend);
Button btnConnect = findViewById(R.id.btnConnect);
btnConnect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tvMessages.setText("");
SERVER_IP = etIP.getText().toString().trim();
SERVER_PORT =
Integer.parseInt(etPort.getText().toString().trim());
Thread1 = new Thread(new Thread1());
Thread1.start();
}
});
btnSend.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String message = etMessage.getText().toString().trim();
if (!message.isEmpty()) {
new Thread(new Thread3(message)).start();
}
}
});
}
private PrintWriter output;
private BufferedReader input;
class Thread1 implements Runnable {
@Override
public void run() {
Socket socket;
try {
socket = new Socket(SERVER_IP, SERVER_PORT);
output = new PrintWriter(socket.getOutputStream());
input = new BufferedReader(new
InputStreamReader(socket.getInputStream()));
runOnUiThread(new Runnable() {
@Override
public void run() {
tvMessages.setText("Connected\n");
}
});
new Thread(new Thread2()).start();
} catch (IOException e) {
e.printStackTrace();
}
}
}
class Thread2 implements Runnable {
@Override
public void run() {
while (true) {
try {
final String message = input.readLine();
if (message ! = null) {
runOnUiThread(new Runnable() {
@Override
public void run() {
tvMessages.append("server: " + message +
"\n");
}
});
} else {
Thread1 = new Thread(new Thread1());
Thread1.start();
return;
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
class Thread3 implements Runnable {
private String message;
Thread3(String message) {
this.message = message;
}
@Override
public void run() {
output.write(message);
output.flush();
runOnUiThread(new Runnable() {
@Override
public void run() {
tvMessages.append("client: " + message + "\n");
etMessage.setText("");
}
});
}
}
}
Step 4 − Add the following code to androidManifest.xml
<?xml version = "1.0" encoding = "utf-8"?>
<manifest xmlns:android =
"http://schemas.android.com/apk/res/android"
package = "com.client.myapplication.client">
<uses-permission android:name = "android.permission.INTERNET" />
<uses-permission android:name =
"android.permission.ACCESS_NETWORK_STATE" />
<application
android:allowBackup = "true"
android:icon = "@mipmap/ic_launcher"
android:label = "@string/app_name"
android:roundIcon = "@mipmap/ic_launcher_round"
android:supportsRtl = "true"
android:theme = "@style/AppTheme">
<activity
android:name =
"com.client.myapplication.clienlt.MainActivity"
android:label = "Client">
<intent-filter>
<action android:name = "android.intent.action.MAIN" />
<category android:name =
"android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Q. Write a short note on :
Advanced NFC
This document goes over the APIs that enable use of the various tag
technologies that Android supports. When you are not working with NDEF
data, or when you are working with NDEF data that Android cannot fully
understand, you have to manually read or write to the tag in raw bytes using
your own protocol stack. In these cases, Android provides support to detect
certain tag technologies and to open communication with the tag using your
own protocol stack.
The Android NDK provides a set of native headers and shared library files that
has gradually increased with successive releases of new Android API levels. This
page explains these headers and files, and maps them to specific Android API
levels.
Overview
There are two basic steps to enable your app to use the libraries that the NDK
provides:
1. Include in your code the headers associated with the libraries you wish to
use.
2. Tell the build system that your native module needs to link against the
libraries at load time. For example, to link
against /system/lib/libfoo.so, add the following line to
your Android.mk file:
LOCAL_LDLIBS := -lfoo
Shadows :
Shadows classes :
Shadow classes always need a public no-arg constructor so that the
Robolectric framework can instantiate them. They are associated to the
class that they Shadow with an @Implements annotation on the class
declaration.
Shadow classes should mimic the production classes’ inheritance
hierarchy. For example, if you are implementing a Shadow
for ViewGroup, ShadowViewGroup, then your Shadow class should
extend ViewGroup’s superclass’s Shadow, ShadowView
Methods
Shadow objects implement methods that have the same signature as the
Android class. Robolectric will invoke the method on a Shadow object when
a method with the same signature on the Android object is invoked.
this.imageView.setImageResource(R.drawable.pivotallabs_log
o);
...
Gradients :
The user interface (UI) of modern apps is improving all the time.
Designers are experimenting with various styles and color combinations to
see which ones work best with the Android App. GradientDrawable is a
key component of Android that is commonly used these days.
XML
<Button
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
android:text="Geeks for Geeks"
android:background="#00FFFF"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
Create a new file gfg color drawable.xml in the drawable package and
enter the following code:
XML
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="45"
android:startColor="#D98880"
android:centerColor="#F4D03F"
android:endColor="#48C9B0"/>
</shape>
We’ve used the <gradient /> tag and added three colour codes: startColor,
centerColor, and endColor.
Roll No.(infigures Code of Paper
packaes
&SLH Databan
Obycct
pdatc Delte
d
fuluedt SQtuDtubayc nt Dadrhme)acttnve
1
tctimu
Callcd c c tRoy heut ttthe applicathn Coulltu
oldVuran, t wwVunen
epade SQLH Databast db t
Culy talld oenira e a updatto
iKVt m o Mtoupdatu a
*o eRLment naluw ot yaluue
vaRiable pawmd m a &uclos ogwsiAUct
vidleu
mUpgtad mod w Cam wite qLLeRNe
putem
updat
lo pesie-m wmet, a d , claloke und
epatowt h e e au two ways
Ruaol eleletu
ww mhult fwetowa tu cel
p date doeta Thase operatiows eloctd
e pdatu
sQLtcBatabaçe clona
wwwties pAovlded
candidate.
Page No. 2. Sign. Of the
Roll No.in figures) Code of Paper
Puv uues
to o
aw
e ut t Cpaatron. Movwevt, wtBk paumeteEa
qceies huchm, a au atuintd tei
&Cus e fuue & oplatiom
h 0.
5
Signature of the Candidate