1 / 11

COMP3670/COMP7090

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.

Antony
Télécharger la présentation

COMP3670/COMP7090

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. 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); }

  3. 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. } });

  4. 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>

  5. 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

  6. COMP3670/COMP7090 Location Services – Google Map API Getting the MD5 Fingerprint of Your Signing Certificate

  7. 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

  8. COMP3670/COMP7090 Location Services – Google Map API Sign with your MD5 Certificate:http://code.google.com/android/maps-api-signup.html

  9. 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

  10. 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.

  11. COMP3670/COMP7090 Try to troubleshot yourself when you copy and paste the text, Import any necessary library, find out what you need in google.

More Related