SlideShare a Scribd company logo
1 of 8
Expe-7
Develop a native application that
uses GPS location information
Android location APIs make it easy for you to build location-
aware applications, without needing to focus on the details of
the underlying location technology.
The Location Object
The Location object represents a geographic location
which can consist of a latitude, longitude, time stamp,
and other information such as bearing, altitude and
velocity. There are following important methods which
you can use with Location object to get location specific
information −
Sr.No. Method & Description
1 float distanceTo(Location dest)
Returns the approximate distance in meters between this location and the given location.
2 float getAccuracy()
Get the estimated accuracy of this location, in meters.
3 double getAltitude()
Get the altitude if available, in meters above sea level.
4 float getBearing()
Get the bearing, in degrees.
5 double getLatitude()
Get the latitude, in degrees.
6 double getLongitude()
Get the longitude, in degrees.
7 float getSpeed()
Get the speed if it is available, in meters/second over ground.
8 boolean hasAccuracy()
True if this location has an accuracy.
9 boolean hasAltitude()
True if this location has an altitude.
10 boolean hasBearing()
True if this location has a bearing.
11 boolean hasSpeed()
True if this location has a speed.
12 void reset()
Clears the contents of the location.
13 void setAccuracy(float accuracy)
Set the estimated accuracy of this location, meters.
14 void setAltitude(double altitude)
Set the altitude, in meters above sea level.
15 void setBearing(float bearing)
Set the bearing, in degrees.
16 void setLatitude(double latitude)
Set the latitude, in degrees.
17 void setLongitude(double longitude)
Set the longitude, in degrees.
Get the Current Location
 To get the current location, create a location client
which is LocationClient object, connect it to Location
Services using connect() method, and then call
its getLastLocation() method. This method returns
the most recent location in the form
of Location object that contains latitude and longitude
coordinates and other information as explained
above. To have location based functionality in your
activity, you will have to implement two interfaces −
 GooglePlayServicesClient.ConnectionCallbacks
 GooglePlayServicesClient.OnConnectionFailedListen
er
 These interfaces provide following important callback
methods, which you need to implement in your activity
Sr.
No.
Callback Methods & Description
1 abstract void onConnected(Bundle connectionHint)
This callback method is called when location service is connected to
the location client successfully. You will use connect() method to
connect to the location client.
2 abstract void onDisconnected()
This callback method is called when the client is disconnected. You will
use disconnect() method to disconnect from the location client.
3 abstract void onConnectionFailed(ConnectionResult result)
This callback method is called when there was an error connecting the
client to the service.
Location Quality of Service
Sr.N
o.
Method & Description
1 setExpirationDuration(long millis)
Set the duration of this request, in milliseconds.
2 setExpirationTime(long millis)
Set the request expiration time, in millisecond since boot.
3 setFastestInterval(long millis)
Explicitly set the fastest interval for location updates, in milliseconds.
4 setInterval(long millis)
Set the desired interval for active location updates, in milliseconds.
5 setNumUpdates(int numUpdates)
Set the number of location updates.
6 setPriority(int priority)
Set the priority of the request.
Create Android Application
Step Description
1 You will use Android studio IDE to create an Android
application
2 add src/GPSTracker.java file and add required code.
3 Modify src/MainActivity.java file and add required code as
shown below to take care of getting current location and its
equivalent address.
4 Modify layout XML file res/layout/activity_main.xml to add
all GUI components which include three buttons and two
text views to show location/address.
5 Modify res/values/strings.xml to define required constant
values
6 Modify AndroidManifest.xml as shown below
7 Run the application to launch Android emulator and verify
the result of the changes done in the application.
File locations
 res/layout/activity_main.xml
 res/values/strings.xml

More Related Content

What's hot

Mobile computing notes and material
Mobile computing notes and materialMobile computing notes and material
Mobile computing notes and materialSDMCET DHARWAD
 
Unit 1 - mobile computing introduction
Unit 1 - mobile computing introductionUnit 1 - mobile computing introduction
Unit 1 - mobile computing introductionVintesh Patel
 
IEEE 802.11 Architecture and Services
IEEE 802.11 Architecture and ServicesIEEE 802.11 Architecture and Services
IEEE 802.11 Architecture and ServicesSayed Chhattan Shah
 
Handover in Mobile Computing
Handover in Mobile ComputingHandover in Mobile Computing
Handover in Mobile ComputingKABILESH RAMAR
 
Multiplexing in mobile computing
Multiplexing in mobile computingMultiplexing in mobile computing
Multiplexing in mobile computingZituSahu
 
Token Ring : 802.5
Token Ring : 802.5Token Ring : 802.5
Token Ring : 802.5Pnkj_Sharma
 
Design issues for the layers
Design issues for the layersDesign issues for the layers
Design issues for the layersjayaprakash
 
Architecture of Mobile Computing
Architecture of Mobile ComputingArchitecture of Mobile Computing
Architecture of Mobile ComputingJAINIK PATEL
 
IEEE STANDARDS 802.3,802.4,802.5
IEEE STANDARDS 802.3,802.4,802.5IEEE STANDARDS 802.3,802.4,802.5
IEEE STANDARDS 802.3,802.4,802.5Eslam Abdou
 
Transport services
Transport servicesTransport services
Transport servicesNavin Kumar
 
EC8004 - Wireless Networks Question Bank
EC8004 - Wireless Networks Question BankEC8004 - Wireless Networks Question Bank
EC8004 - Wireless Networks Question BankKannanKrishnana
 
Mobile Network Layer
Mobile Network LayerMobile Network Layer
Mobile Network LayerRahul Hada
 
Multiplexing ppt15 sep
Multiplexing ppt15 sepMultiplexing ppt15 sep
Multiplexing ppt15 sepSrashti Vyas
 

What's hot (20)

Mobile computing notes and material
Mobile computing notes and materialMobile computing notes and material
Mobile computing notes and material
 
Unit 1 - mobile computing introduction
Unit 1 - mobile computing introductionUnit 1 - mobile computing introduction
Unit 1 - mobile computing introduction
 
IEEE 802.11 Architecture and Services
IEEE 802.11 Architecture and ServicesIEEE 802.11 Architecture and Services
IEEE 802.11 Architecture and Services
 
Handover in Mobile Computing
Handover in Mobile ComputingHandover in Mobile Computing
Handover in Mobile Computing
 
Multiplexing in mobile computing
Multiplexing in mobile computingMultiplexing in mobile computing
Multiplexing in mobile computing
 
Chapter 2: Network Models
Chapter 2: Network ModelsChapter 2: Network Models
Chapter 2: Network Models
 
Token Ring : 802.5
Token Ring : 802.5Token Ring : 802.5
Token Ring : 802.5
 
Design issues for the layers
Design issues for the layersDesign issues for the layers
Design issues for the layers
 
Architecture of Mobile Computing
Architecture of Mobile ComputingArchitecture of Mobile Computing
Architecture of Mobile Computing
 
Gsm architecture
Gsm architectureGsm architecture
Gsm architecture
 
Chapter 13
Chapter 13Chapter 13
Chapter 13
 
IEEE STANDARDS 802.3,802.4,802.5
IEEE STANDARDS 802.3,802.4,802.5IEEE STANDARDS 802.3,802.4,802.5
IEEE STANDARDS 802.3,802.4,802.5
 
Mobile IP
Mobile IPMobile IP
Mobile IP
 
Transport services
Transport servicesTransport services
Transport services
 
Chapter 12
Chapter 12Chapter 12
Chapter 12
 
UMTS, Introduction.
UMTS, Introduction.UMTS, Introduction.
UMTS, Introduction.
 
EC8004 - Wireless Networks Question Bank
EC8004 - Wireless Networks Question BankEC8004 - Wireless Networks Question Bank
EC8004 - Wireless Networks Question Bank
 
Mobile Network Layer
Mobile Network LayerMobile Network Layer
Mobile Network Layer
 
Multiplexing ppt15 sep
Multiplexing ppt15 sepMultiplexing ppt15 sep
Multiplexing ppt15 sep
 
Ad-Hoc Networks
Ad-Hoc NetworksAd-Hoc Networks
Ad-Hoc Networks
 

Similar to Develop a native application that uses GPS location.pptx

How to use geolocation in react native apps
How to use geolocation in react native appsHow to use geolocation in react native apps
How to use geolocation in react native appsInnovationM
 
International Journal of Engineering Research and Development
International Journal of Engineering Research and DevelopmentInternational Journal of Engineering Research and Development
International Journal of Engineering Research and DevelopmentIJERD Editor
 
Windows phone 7 series
Windows phone 7 seriesWindows phone 7 series
Windows phone 7 seriesopenbala
 
Mobile Application Development-Lecture 15 & 16.pdf
Mobile Application Development-Lecture 15 & 16.pdfMobile Application Development-Lecture 15 & 16.pdf
Mobile Application Development-Lecture 15 & 16.pdfAbdullahMunir32
 
MBLTDev: Phillip Connaughton, RunKepper
MBLTDev: Phillip Connaughton, RunKepper MBLTDev: Phillip Connaughton, RunKepper
MBLTDev: Phillip Connaughton, RunKepper e-Legion
 
Battery Efficient Location Services
Battery Efficient Location ServicesBattery Efficient Location Services
Battery Efficient Location ServicesArun Nagarajan
 
Boldly Go Where No Man Has Gone Before. Explore Geo on iPhone & Android
Boldly Go Where No Man Has Gone Before. Explore Geo on iPhone & AndroidBoldly Go Where No Man Has Gone Before. Explore Geo on iPhone & Android
Boldly Go Where No Man Has Gone Before. Explore Geo on iPhone & AndroidBess Ho
 
Android location and sensors API
Android location and sensors APIAndroid location and sensors API
Android location and sensors APIeleksdev
 
Smart Way to Track the Location in Android Operating System
Smart Way to Track the Location in Android Operating SystemSmart Way to Track the Location in Android Operating System
Smart Way to Track the Location in Android Operating SystemIOSR Journals
 
097 smart devices-con_las_aplicaciones_de_gestión
097 smart devices-con_las_aplicaciones_de_gestión097 smart devices-con_las_aplicaciones_de_gestión
097 smart devices-con_las_aplicaciones_de_gestiónGeneXus
 
Corso WebApp iOS - Lezione 07: iOS WebApp Anatomy
Corso WebApp iOS - Lezione 07: iOS WebApp AnatomyCorso WebApp iOS - Lezione 07: iOS WebApp Anatomy
Corso WebApp iOS - Lezione 07: iOS WebApp AnatomyAndrea Picchi
 
Developing Windows Phone Apps with Maps and Location Services
Developing Windows Phone Apps with Maps and Location ServicesDeveloping Windows Phone Apps with Maps and Location Services
Developing Windows Phone Apps with Maps and Location ServicesNick Landry
 
Pandora FMS: Windows Phone 7 Agent
Pandora FMS: Windows Phone 7 AgentPandora FMS: Windows Phone 7 Agent
Pandora FMS: Windows Phone 7 AgentPandora FMS
 
Android App Development 04 : Location API
Android App Development 04 : Location APIAndroid App Development 04 : Location API
Android App Development 04 : Location APIAnuchit Chalothorn
 
Android location based services
Android location based servicesAndroid location based services
Android location based servicesaswath babu
 
iOS Core location
iOS Core locationiOS Core location
iOS Core locationRicha Jain
 

Similar to Develop a native application that uses GPS location.pptx (20)

MAD Unit 6.pptx
MAD Unit 6.pptxMAD Unit 6.pptx
MAD Unit 6.pptx
 
How to use geolocation in react native apps
How to use geolocation in react native appsHow to use geolocation in react native apps
How to use geolocation in react native apps
 
International Journal of Engineering Research and Development
International Journal of Engineering Research and DevelopmentInternational Journal of Engineering Research and Development
International Journal of Engineering Research and Development
 
Windows phone 7 series
Windows phone 7 seriesWindows phone 7 series
Windows phone 7 series
 
Mobile Application Development-Lecture 15 & 16.pdf
Mobile Application Development-Lecture 15 & 16.pdfMobile Application Development-Lecture 15 & 16.pdf
Mobile Application Development-Lecture 15 & 16.pdf
 
MBLTDev: Phillip Connaughton, RunKepper
MBLTDev: Phillip Connaughton, RunKepper MBLTDev: Phillip Connaughton, RunKepper
MBLTDev: Phillip Connaughton, RunKepper
 
Core Location in iOS
Core Location in iOSCore Location in iOS
Core Location in iOS
 
Battery Efficient Location Services
Battery Efficient Location ServicesBattery Efficient Location Services
Battery Efficient Location Services
 
Boldly Go Where No Man Has Gone Before. Explore Geo on iPhone & Android
Boldly Go Where No Man Has Gone Before. Explore Geo on iPhone & AndroidBoldly Go Where No Man Has Gone Before. Explore Geo on iPhone & Android
Boldly Go Where No Man Has Gone Before. Explore Geo on iPhone & Android
 
report
reportreport
report
 
Android location and sensors API
Android location and sensors APIAndroid location and sensors API
Android location and sensors API
 
Location based services
Location based servicesLocation based services
Location based services
 
Smart Way to Track the Location in Android Operating System
Smart Way to Track the Location in Android Operating SystemSmart Way to Track the Location in Android Operating System
Smart Way to Track the Location in Android Operating System
 
097 smart devices-con_las_aplicaciones_de_gestión
097 smart devices-con_las_aplicaciones_de_gestión097 smart devices-con_las_aplicaciones_de_gestión
097 smart devices-con_las_aplicaciones_de_gestión
 
Corso WebApp iOS - Lezione 07: iOS WebApp Anatomy
Corso WebApp iOS - Lezione 07: iOS WebApp AnatomyCorso WebApp iOS - Lezione 07: iOS WebApp Anatomy
Corso WebApp iOS - Lezione 07: iOS WebApp Anatomy
 
Developing Windows Phone Apps with Maps and Location Services
Developing Windows Phone Apps with Maps and Location ServicesDeveloping Windows Phone Apps with Maps and Location Services
Developing Windows Phone Apps with Maps and Location Services
 
Pandora FMS: Windows Phone 7 Agent
Pandora FMS: Windows Phone 7 AgentPandora FMS: Windows Phone 7 Agent
Pandora FMS: Windows Phone 7 Agent
 
Android App Development 04 : Location API
Android App Development 04 : Location APIAndroid App Development 04 : Location API
Android App Development 04 : Location API
 
Android location based services
Android location based servicesAndroid location based services
Android location based services
 
iOS Core location
iOS Core locationiOS Core location
iOS Core location
 

More from vishal choudhary (20)

SE-Lecture1.ppt
SE-Lecture1.pptSE-Lecture1.ppt
SE-Lecture1.ppt
 
SE-Testing.ppt
SE-Testing.pptSE-Testing.ppt
SE-Testing.ppt
 
SE-CyclomaticComplexityand Testing.ppt
SE-CyclomaticComplexityand Testing.pptSE-CyclomaticComplexityand Testing.ppt
SE-CyclomaticComplexityand Testing.ppt
 
SE-Lecture-7.pptx
SE-Lecture-7.pptxSE-Lecture-7.pptx
SE-Lecture-7.pptx
 
Se-Lecture-6.ppt
Se-Lecture-6.pptSe-Lecture-6.ppt
Se-Lecture-6.ppt
 
SE-Lecture-5.pptx
SE-Lecture-5.pptxSE-Lecture-5.pptx
SE-Lecture-5.pptx
 
XML.pptx
XML.pptxXML.pptx
XML.pptx
 
SE-Lecture-8.pptx
SE-Lecture-8.pptxSE-Lecture-8.pptx
SE-Lecture-8.pptx
 
SE-coupling and cohesion.ppt
SE-coupling and cohesion.pptSE-coupling and cohesion.ppt
SE-coupling and cohesion.ppt
 
SE-Lecture-2.pptx
SE-Lecture-2.pptxSE-Lecture-2.pptx
SE-Lecture-2.pptx
 
SE-software design.ppt
SE-software design.pptSE-software design.ppt
SE-software design.ppt
 
SE1.ppt
SE1.pptSE1.ppt
SE1.ppt
 
SE-Lecture-4.pptx
SE-Lecture-4.pptxSE-Lecture-4.pptx
SE-Lecture-4.pptx
 
SE-Lecture=3.pptx
SE-Lecture=3.pptxSE-Lecture=3.pptx
SE-Lecture=3.pptx
 
Multimedia-Lecture-Animation.pptx
Multimedia-Lecture-Animation.pptxMultimedia-Lecture-Animation.pptx
Multimedia-Lecture-Animation.pptx
 
MultimediaLecture5.pptx
MultimediaLecture5.pptxMultimediaLecture5.pptx
MultimediaLecture5.pptx
 
Multimedia-Lecture-7.pptx
Multimedia-Lecture-7.pptxMultimedia-Lecture-7.pptx
Multimedia-Lecture-7.pptx
 
MultiMedia-Lecture-4.pptx
MultiMedia-Lecture-4.pptxMultiMedia-Lecture-4.pptx
MultiMedia-Lecture-4.pptx
 
Multimedia-Lecture-6.pptx
Multimedia-Lecture-6.pptxMultimedia-Lecture-6.pptx
Multimedia-Lecture-6.pptx
 
Multimedia-Lecture-3.pptx
Multimedia-Lecture-3.pptxMultimedia-Lecture-3.pptx
Multimedia-Lecture-3.pptx
 

Recently uploaded

ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 

Recently uploaded (20)

Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 

Develop a native application that uses GPS location.pptx

  • 1. Expe-7 Develop a native application that uses GPS location information
  • 2. Android location APIs make it easy for you to build location- aware applications, without needing to focus on the details of the underlying location technology. The Location Object The Location object represents a geographic location which can consist of a latitude, longitude, time stamp, and other information such as bearing, altitude and velocity. There are following important methods which you can use with Location object to get location specific information −
  • 3. Sr.No. Method & Description 1 float distanceTo(Location dest) Returns the approximate distance in meters between this location and the given location. 2 float getAccuracy() Get the estimated accuracy of this location, in meters. 3 double getAltitude() Get the altitude if available, in meters above sea level. 4 float getBearing() Get the bearing, in degrees. 5 double getLatitude() Get the latitude, in degrees. 6 double getLongitude() Get the longitude, in degrees. 7 float getSpeed() Get the speed if it is available, in meters/second over ground. 8 boolean hasAccuracy() True if this location has an accuracy. 9 boolean hasAltitude() True if this location has an altitude. 10 boolean hasBearing() True if this location has a bearing. 11 boolean hasSpeed() True if this location has a speed. 12 void reset() Clears the contents of the location. 13 void setAccuracy(float accuracy) Set the estimated accuracy of this location, meters. 14 void setAltitude(double altitude) Set the altitude, in meters above sea level. 15 void setBearing(float bearing) Set the bearing, in degrees. 16 void setLatitude(double latitude) Set the latitude, in degrees. 17 void setLongitude(double longitude) Set the longitude, in degrees.
  • 4. Get the Current Location  To get the current location, create a location client which is LocationClient object, connect it to Location Services using connect() method, and then call its getLastLocation() method. This method returns the most recent location in the form of Location object that contains latitude and longitude coordinates and other information as explained above. To have location based functionality in your activity, you will have to implement two interfaces −  GooglePlayServicesClient.ConnectionCallbacks  GooglePlayServicesClient.OnConnectionFailedListen er  These interfaces provide following important callback methods, which you need to implement in your activity
  • 5. Sr. No. Callback Methods & Description 1 abstract void onConnected(Bundle connectionHint) This callback method is called when location service is connected to the location client successfully. You will use connect() method to connect to the location client. 2 abstract void onDisconnected() This callback method is called when the client is disconnected. You will use disconnect() method to disconnect from the location client. 3 abstract void onConnectionFailed(ConnectionResult result) This callback method is called when there was an error connecting the client to the service.
  • 6. Location Quality of Service Sr.N o. Method & Description 1 setExpirationDuration(long millis) Set the duration of this request, in milliseconds. 2 setExpirationTime(long millis) Set the request expiration time, in millisecond since boot. 3 setFastestInterval(long millis) Explicitly set the fastest interval for location updates, in milliseconds. 4 setInterval(long millis) Set the desired interval for active location updates, in milliseconds. 5 setNumUpdates(int numUpdates) Set the number of location updates. 6 setPriority(int priority) Set the priority of the request.
  • 7. Create Android Application Step Description 1 You will use Android studio IDE to create an Android application 2 add src/GPSTracker.java file and add required code. 3 Modify src/MainActivity.java file and add required code as shown below to take care of getting current location and its equivalent address. 4 Modify layout XML file res/layout/activity_main.xml to add all GUI components which include three buttons and two text views to show location/address. 5 Modify res/values/strings.xml to define required constant values 6 Modify AndroidManifest.xml as shown below 7 Run the application to launch Android emulator and verify the result of the changes done in the application.