1 / 11

comp3670comp7090 location services easier example - PowerPoint PPT Presentation

  • Updated On :

COMP3670/COMP7090. Location Services – Easier Example. locationManager= (LocationManager)getSystemService(Context.LOCATION_SERVICE ); List<String> providers= locationManager.getAllProviders(); for(String p:providers){ // Process & Provider }. COMP3670/COMP7090.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'comp3670comp7090 location services easier example' - Antony

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Slide1 l.jpg


Location Services – Easier Example

locationManager= (LocationManager)getSystemService(Context.LOCATION_SERVICE);

List<String> providers= locationManager.getAllProviders();

for(String p:providers){

//Process & Provider


Slide2 l.jpg


Location Services – To find out the best provider

Private String findProvider(){

Criteria criteria = new Criteria();



criteria.setAlititudeRequired(false); //

criteria.setBearingRequired(false); //

criteria.setSpeedRequired(false); //Speed

criteria.setCostAllowed(true); //

return locationManager.getBestProvider(criteria, ture);


Slide3 l.jpg


Location Services – Get the current location

  • getLastKnownLocation()

    • //Get the last know location

  • requestLocationUpdate(String provider, long minTime, float minDistance, LocationListener listener)

    • minTime://return time

    • float minDistance:return distance interval.

locationManager.requestLocationUpdate(locationManager.AGPS_PROVIDER,60000, 10, new LocationListener(){

public void onLocationChanged(Location location){

//update the position and logic.



Slide4 l.jpg


Location Services – Your Manifest.xml , User-permission

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android=""




<application android:icon="@drawable/icon" android:label="@string/app_name">

<activity android:name=".ButtonTest"



<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />




<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />

<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />

<uses-permission android:name="android.permission.CONTROL_LOCATION_UPDATES" />

<uses-permission android:name="android.permission.INTERNET" />


Slide5 l.jpg


Location Services – Download Google API SDK

For further Information, please visit:

Remember to use “Android APIs” as a Emulator

Some Application may need Android 2.3.3, API 10

Slide6 l.jpg


Location Services – Google Map API

Getting the MD5 Fingerprint of Your Signing Certificate

Slide7 l.jpg


Location Services – Google Map API

For further Information, please visit:

Slide8 l.jpg


Location Services – Google Map API

Sign with your MD5 Certificate:

Slide9 l.jpg


Location Services – Adding the Maps API Key to your Application

Once you've registered with the Google Maps service and have obtained a Maps API Key, you must add it to your application's MapView objects, so that the Maps server will allow them to download Maps tiles.

For <MapView> elements declared in XML layout files, add the Maps API Key as the value of a special attribute — android:apiKey. For example:

< android:layout_width="fill_parent" android:layout_height="fill_parent" android:enabled="true" android:clickable="true" android:apiKey="example_Maps_ApiKey_String" />

For MapView objects instantiated directly from code, pass the Maps API Key string as a parameter in the constructor. For example:

mMapView = new MapView(this, "example_Maps_ApiKey_String");

For more information about MapView, see the MapView class Documentation.

Slide10 l.jpg


Location Services – Final Steps to Enable MapView Elements

If you've added the Maps API Key to the MapViews in your application, here are the final steps to enable the MapView elements to run properly:

Make sure that you added a <uses-library> element referencing the external library. The element must be a child of the <application> element in the application's manifest. For example:

<manifest xmlns:android="" package=""> ...

<application android:name="MyApplication" >

<uses-library android:name="" /> ...


Sign your application with the certificate that corresponds to the Maps API Key referenced in your MapView elements.

Note that, when you are ready to publish your application, you must get a Maps API Key that is based on the certificate that you will use to sign the application for release. You must then change the Maps API Key strings referenced by all of your MapView elements, so that they reference the new Key.

Slide11 l.jpg


Try to troubleshot yourself when you copy and paste the text,

Import any necessary library, find out what you need in google.