slide1 n.
Skip this Video
Loading SlideShow in 5 Seconds..
COMP3670/COMP7090 PowerPoint Presentation
Download Presentation


289 Views Download Presentation
Download Presentation


- - - - - - - - - - - - - - - - - - - - - - - - - - - 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="" package="" 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: 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:

  8. COMP3670/COMP7090 Location Services – Google Map API Sign with your MD5 Certificate:

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

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