COMP3670/COMP7090
Download
1 / 11

comp3670comp7090 location services easier example - PowerPoint PPT Presentation


  • 233 Views
  • 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.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
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

COMP3670/COMP7090

Location Services – Easier Example

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

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

for(String p:providers){

//Process & Provider

}


Slide2 l.jpg

COMP3670/COMP7090

Location Services – To find out the best provider

Private String findProvider(){

Criteria criteria = new Criteria();

criteria.setAccuracy(Criteria.ACCURACY_COARSE);

criteria.setPowerRequirement(Criteria.POWER_LOW);

criteria.setAlititudeRequired(false); //

criteria.setBearingRequired(false); //

criteria.setSpeedRequired(false); //Speed

criteria.setCostAllowed(true); //

return locationManager.getBestProvider(criteria, ture);

}


Slide3 l.jpg

COMP3670/COMP7090

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

COMP3670/COMP7090

Location Services – Your Manifest.xml , User-permission

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

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

package="com.example.android.ButtonTest"

android:versionCode="1"

android:versionName="1.0">

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

<activity android:name=".ButtonTest"

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>

<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" />

</manifest>


Slide5 l.jpg

COMP3670/COMP7090

Location Services – Download Google API SDK

For further Information, please visit: http://code.google.com/intl/zh-TW/android/add-ons/google-apis/

Remember to use “Android APIs” as a Emulator

Some Application may need Android 2.3.3, API 10


Slide6 l.jpg

COMP3670/COMP7090

Location Services – Google Map API

Getting the MD5 Fingerprint of Your Signing Certificate


Slide7 l.jpg

COMP3670/COMP7090

Location Services – Google Map API

For further Information, please visit: http://code.google.com/intl/zh-TW/android/add-ons/google-apis/mapkey.html


Slide8 l.jpg

COMP3670/COMP7090

Location Services – Google Map API

Sign with your MD5 Certificate:http://code.google.com/android/maps-api-signup.html


Slide9 l.jpg

COMP3670/COMP7090

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:

<com.google.android.maps.MapView 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.

http://code.google.com/android/add-ons/google-apis/reference/com/google/android/maps/MapView.html


Slide10 l.jpg

COMP3670/COMP7090

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 com.google.android.maps library. The element must be a child of the <application> element in the application's manifest. For example:

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.package.name"> ...

<application android:name="MyApplication" >

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

</application>

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

COMP3670/COMP7090

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

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


ad