advanced android - godspeed

59
Advanced Android Features By Rohit Ghatol From Pune Google Technology User Group http://pune-gtug.blogspot.com

Upload: rohit-ghatol

Post on 17-May-2015

1.949 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Advanced Android - GodSpeed

Advanced Android Features

By Rohit GhatolFrom

Pune Google Technology User Grouphttp://pune-gtug.blogspot.com

Page 2: Advanced Android - GodSpeed

What is Pune-GTUG?

GTUG stands for Google Technology User Group

Page 3: Advanced Android - GodSpeed

Advanced Android Features

Page 4: Advanced Android - GodSpeed

GodSpeed Application

• Name - GodSpeed • Purpose – Turn by Turn GPS Navigation• Status – In Development• Synopsis

o Use can type in the name of the location the user wants to go and GodSpeed will show on the Map the way to reach there. Also, GodSpeed will inform the user using Voice, when a turn is coming. The Map can rotate to make it easier for the user to understand where to head

Page 5: Advanced Android - GodSpeed

GodSpeed Application In Action

Page 6: Advanced Android - GodSpeed

GodSpeed Application In Action

Page 7: Advanced Android - GodSpeed

GodSpeed Application In Action

Page 8: Advanced Android - GodSpeed

GodSpeed Application In Action

Page 9: Advanced Android - GodSpeed

GodSpeed Application In Action

Page 10: Advanced Android - GodSpeed

GodSpeed Application In Action

Page 11: Advanced Android - GodSpeed

GodSpeed Application In Action

Page 12: Advanced Android - GodSpeed

GodSpeed Application In Action

Page 13: Advanced Android - GodSpeed

GodSpeed Application In Action

Page 14: Advanced Android - GodSpeed

GodSpeed Application In Action

Page 15: Advanced Android - GodSpeed

GodSpeed Application In Action

Page 16: Advanced Android - GodSpeed

GodSpeed Application In Action

Page 17: Advanced Android - GodSpeed

GodSpeed Application In Action

Page 18: Advanced Android - GodSpeed

GodSpeed Application In Action

Page 19: Advanced Android - GodSpeed

GodSpeed Application In Action

Page 20: Advanced Android - GodSpeed

GodSpeed Application In Action

Page 21: Advanced Android - GodSpeed

GodSpeed Application In Action

Page 22: Advanced Android - GodSpeed

GodSpeed Application In Action

Page 23: Advanced Android - GodSpeed

GodSpeed Application In Action

Page 24: Advanced Android - GodSpeed

GodSpeed Application In Action

Page 25: Advanced Android - GodSpeed

GodSpeed Application In Action

Page 26: Advanced Android - GodSpeed

GodSpeed Application In Action

Page 27: Advanced Android - GodSpeed

Android Feature List

• Use of Relative Layout• Use of MapView• Use of GPS (LocationManager and

Geocoder)• Use of Google Directions• Use of Sensors• Use of ViewGroup

Page 28: Advanced Android - GodSpeed

GodSpeed Building Blocks

GodSpeed Activity DestinationSelector Activity

+ -

Deccan, Pune Enter Destination

Get Direction

Page 29: Advanced Android - GodSpeed

GodSpeed Building Blocks

GodSpeed Activity

+ -

Deccan, Pune RelativeLayout

TextView

LinearLayout

Button

ViewGroup

MapView

Page 30: Advanced Android - GodSpeed

GodSpeed Building Blocks

GodSpeed Activity DestinationSelector Activity

+ -

Deccan, Pune Enter Destination

Get Direction

____ _____

Get Direction Enable Compass

Invoke activity using context.startActivityForResult()

Page 31: Advanced Android - GodSpeed

GodSpeed Building Blocks

DestinationSelector Activity

Enter Destination

Aditya Garden City,Pune

Get Direction

GodSpeed Activity

+ -

Deccan, Pune

SetResult with Intent containing Address and finish activity

Page 32: Advanced Android - GodSpeed

GodSpeed Building Blocks

GodSpeed Activity

+ -

Deccan, Pune 1. Google Direction is used to get the route

2. Google Direction returns way points shown by marker

3. It also returns encoded Polyline, shown as blue line

4. Overlay is used to plot the Markers and the blue line

Page 33: Advanced Android - GodSpeed

GodSpeed Rotation Explained

GodSpeed Activity

Rotate3DView

ViewGroup

dispatchDraw(Canvas canvas)

SensorListener

onSensorChanged()

1. onSensorChanged invalidate() is called

2. This calls the dispatchDraw() of ViewGroup

3. Canvas is rotated

Page 34: Advanced Android - GodSpeed

GodSpeed Turn by Turn Voice Notification (Yet to be implemented)

GodSpeed Activity

1. Use LocationManager’s1. addProximityAlert to add latitude

and longitude of the next way pointOR

2. requestLocationUpdates() to get constant update on location. Check whether we are in proximity of next way point

And once we are in proximity use TTS library to yell out to the end user

Page 35: Advanced Android - GodSpeed

Use of Relative Layout

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical" android:layout_width="fill_parent"android:layout_height="wrap_content">

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical" android:id="@+id/mapview"android:layout_width="fill_parent" android:layout_height="fill_parent"></LinearLayout>

<TextView android:id="@+id/currentLocation" android:textColor="#000000"android:layout_width="wrap_content" android:layout_height="wrap_content"android:layout_alignTop="@+id/mapview"android:layout_centerHorizontal="true"></TextView>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="horizontal" android:id="@+id/zoomControl"android:layout_width="wrap_content" android:layout_height="wrap_content"android:layout_alignBottom="@+id/mapview" android:layout_centerHorizontal="true"><Button android:id="@+id/zoomIn" android:text="+" android:layout_width="80px" android:layout_height="wrap_content" android:textSize="12pt" android:textStyle="bold"/><Button android:id="@+id/zoomOut" android:text="-" android:layout_width="80px" android:layout_height="wrap_content" android:textSize="12pt" android:textStyle="bold"/></LinearLayout></RelativeLayout>

Page 36: Advanced Android - GodSpeed

Use of Relative Layout

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical" android:layout_width="fill_parent"android:layout_height="wrap_content">

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical" android:id="@+id/mapview"android:layout_width="fill_parent" android:layout_height="fill_parent"></LinearLayout>

<TextView android:id="@+id/currentLocation" android:textColor="#000000"android:layout_width="wrap_content" android:layout_height="wrap_content"android:layout_alignTop="@+id/mapview"android:layout_centerHorizontal="true"></TextView>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="horizontal" android:id="@+id/zoomControl"android:layout_width="wrap_content" android:layout_height="wrap_content"android:layout_alignBottom="@+id/mapview" android:layout_centerHorizontal="true"><Button android:id="@+id/zoomIn" android:text="+" android:layout_width="80px" android:layout_height="wrap_content" android:textSize="12pt" android:textStyle="bold"/><Button android:id="@+id/zoomOut" android:text="-" android:layout_width="80px" android:layout_height="wrap_content" android:textSize="12pt" android:textStyle="bold"/></LinearLayout></RelativeLayout>

Page 37: Advanced Android - GodSpeed

Use of Relative Layout

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical" android:layout_width="fill_parent"android:layout_height="wrap_content">

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical" android:id="@+id/mapview"android:layout_width="fill_parent" android:layout_height="fill_parent"></LinearLayout>

<TextView android:id="@+id/currentLocation" android:textColor="#000000"android:layout_width="wrap_content" android:layout_height="wrap_content"android:layout_alignTop="@+id/mapview"android:layout_centerHorizontal="true"></TextView>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="horizontal" android:id="@+id/zoomControl"android:layout_width="wrap_content" android:layout_height="wrap_content"android:layout_alignBottom="@+id/mapview" android:layout_centerHorizontal="true"><Button android:id="@+id/zoomIn" android:text="+" android:layout_width="80px" android:layout_height="wrap_content" android:textSize="12pt" android:textStyle="bold"/><Button android:id="@+id/zoomOut" android:text="-" android:layout_width="80px" android:layout_height="wrap_content" android:textSize="12pt" android:textStyle="bold"/></LinearLayout></RelativeLayout>

Page 38: Advanced Android - GodSpeed

Use of Relative Layout

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical" android:layout_width="fill_parent"android:layout_height="wrap_content">

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical" android:id="@+id/mapview"android:layout_width="fill_parent" android:layout_height="fill_parent"></LinearLayout>

<TextView android:id="@+id/currentLocation" android:textColor="#000000"android:layout_width="wrap_content" android:layout_height="wrap_content"android:layout_alignTop="@+id/mapview"android:layout_centerHorizontal="true"></TextView>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="horizontal" android:id="@+id/zoomControl"android:layout_width="wrap_content" android:layout_height="wrap_content"android:layout_alignBottom="@+id/mapview" android:layout_centerHorizontal="true"><Button android:id="@+id/zoomIn" android:text="+" android:layout_width="80px" android:layout_height="wrap_content" android:textSize="12pt" android:textStyle="bold"/><Button android:id="@+id/zoomOut" android:text="-" android:layout_width="80px" android:layout_height="wrap_content" android:textSize="12pt" android:textStyle="bold"/></LinearLayout></RelativeLayout>

Page 39: Advanced Android - GodSpeed

Use of MapView

• Prerequisteso The containing Activity has to be MapActivityo Need a API Key - read 

Obtaining a Maps API Keyo Android Manifest requires

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

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

Page 40: Advanced Android - GodSpeed

Use of MapView

• Prerequisteso The containing Activity has to be MapActivityo Need a API Key - read 

Obtaining a Maps API Keyo Android Manifest requires

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

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

Page 41: Advanced Android - GodSpeed

Use of MapView (Manifest)<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.punegtug.godspeed" android:versionCode="1“ android:versionName="1.0">

<application android:icon="@drawable/icon" android:label="@string/app_name“ android:debuggable="true"><uses-library android:name="com.google.android.maps" /><activity android:label="@string/app_name" android:name=".activities.GodSpeed"><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter></activity><activity android:label="@string/app_name" android:name=".activities.DestinationSelector“></activity></application>

<uses-sdk android:minSdkVersion="3" /><uses-permission android:name="android.permission.INTERNET" /><uses-permission android:name="android.permission.ACCESS_GPS" /><uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /><uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /><uses-permission android:name="android.permission.ACCESS_LOCATION" /><uses-permission android:name="android.permission.ACCESS_ASSISTED_GPS" /><uses-permission android:name="android.permission.ACCESS_CELL_ID" /></manifest>

Page 42: Advanced Android - GodSpeed

Simple MapView App (mapView.xml)

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:id="@+id/main"android:layout_width="fill_parent" android:layout_height="fill_parent"><com.google.android.maps.MapViewandroid:layout_width="fill_parent" android:layout_height="fill_parent"android:enabled="true"android:clickable="true"android:apiKey="0hVRfOyOcltfCZDhWLo6B2Hv9S6g-RAMYQoO-eg"/></LinearLayout>

Page 43: Advanced Android - GodSpeed

Simple MapView App(MapViewDemo.java)

import com.example.android.google.apis.R;import com.google.android.maps.MapActivity;import android.os.Bundle;public class MapViewDemo extends MapActivity {@Override public void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState); setContentView(R.layout.mapview); } @Override protected boolean isRouteDisplayed() {return false; }}

Page 44: Advanced Android - GodSpeed

Overlay on MapViewpublic class RouteOverlay extends Overlay {private List<GeoPoint> route=null;public RouteOverlay(List<GeoPoint> route){this.route=route;}@Overridepublic void draw(Canvas canvas, MapView mapView, boolean arg2) {Paint paint = new Paint();paint.setARGB(200, 255, 0, 0);Projection projection=mapView.getProjection();paint.setStrokeWidth(5);paint.setAlpha(50);for(int index=0;index<route.size()-1;index++){Point fromPoint=projection.toPixels(route.get(index), null);Point toPoint=projection.toPixels(route.get(index+1), null);canvas.drawLine(fromPoint.x,fromPoint.y,toPoint.x,toPoint.y, paint);}super.draw(canvas, mapView, arg2);}}

Page 45: Advanced Android - GodSpeed

Use of GPS(LocationManager)

• LocationManager useso Get Current GPS Locationo Add Listeners for GPS Events and Proximity

alertso GPS Events include

Getting status of GPS (whether fix is there or not) Getting latitude and longitude

o Proximity alerts are fired when we are in proximity of a given latitude and longitude

Page 46: Advanced Android - GodSpeed

LocationManager Code

//Getting the current GPS Position

LocationManager manager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);

String provider = manager.getBestProvider(new Criteria(), true);

Location location = manager.getLastKnownLocation(provider);

Page 47: Advanced Android - GodSpeed

LocationManager Code

// Registering for regular updates on GPSpublic void requestLocationUpdates (String provider, long minTime, float minDistance, LocationListener listener)

minTime – millisecondsminDistance – meters

Page 48: Advanced Android - GodSpeed

LocationManager Code// Registering for regular updates on GPSlocationListener = new LocationListener() {

@Override public void onLocationChanged(Location location) { }

@Override public void onProviderDisabled(String provider) { }

@Override public void onProviderEnabled(String provider) { }

@Override // status can be  AVAILABLE, OUT_OF_SERVICE,TEMPORARILY_UNAVAILABLE public void onStatusChanged(String provider, int status, Bundle extras) { }

};

Page 49: Advanced Android - GodSpeed

Use of GPS(Geocoder)

• Geocoder is used to o Get List of Addresses from given texto Get List of GeoPoints from given texto Get List of Addresses from given latitude and

longitude

Page 50: Advanced Android - GodSpeed

Geocoder Code

//Getting geopoint from given address

Geocoder coder=new Geocoder();

List<Address> addresses = coder.getFromLocationName(location, 1);

Page 51: Advanced Android - GodSpeed

Geocoder Code

//Reverse Geocoding - Getting address from given latitude and longitude

Geocoder coder=new Geocoder();

List<Address> addresses = coder.getFromLocation (17.113, 84.12211, 1);

Page 52: Advanced Android - GodSpeed

Use of Google Directions

public String getGeoDirectionURI(GeoPoint from, GeoPoint to) {return "http://maps.google.com/maps/nav?hl=US&gl=US&output=js&oe =utf8&q=from:"+ Utils.getLatitude(from)+ ","+ Utils.getLongitude(from)+ "+to:"+ Utils.getLatitude(to)+ ","+ Utils.getLongitude(to)+ "&key=" + KEY;

}

Page 53: Advanced Android - GodSpeed

Use of Google Directions

Example URL – http://maps.google.com/maps/nav?hl=US&gl=US&output=js&oe=utf8&q=from:18.5167,73.8563+to:19.01973,72.8545&key=ABQIAAAAQQcZviIzmIqVxEaMT12eqxT4XTUArVw0hfaJt-dPnDdoJ_2yihSOjsppgL4ku_kEd5DDd3kEV_K2AQ

Page 54: Advanced Android - GodSpeed

Use of Google DirectionsResponse – {"name":"from:18.5167,73.8563 to:19.01973,72.8545","Status":{"code":200,"request":"directions"},"Placemark":[{"id":"","address":"Shivaji Rd","AddressDetails":{"Thoroughfare":{"ThoroughfareName":"Shivaji Rd"},"Accuracy": 0},"Point":{"coordinates":[73.856300,18.516700,0]}},{"id":"","address":"D.S. Barato Rd","AddressDetails":{"Thoroughfare":{"ThoroughfareName":"D.S. Barato Rd"},"Accuracy": 0},"Point":{"coordinates":[72.854500,19.019730,0]}}],"Directions":{"copyrightsHtml":"Map data \u0026#169;2009 Europa Technologies ","summaryHtml":"158\u0026nbsp;km (about 2 hours 39 mins)","Distance":{"meters":158392,"html":"158\u0026nbsp;km"},"Duration":{"seconds":9561,"html":"2 hours 39 mins"},"Routes":[{"Distance":{"meters":158392,"html":"158\u0026nbsp;km"},"Duration":{"seconds":9561,"html":"2 hours 39 mins"},"summaryHtml":"158\u0026nbsp;km (about 2 hours 39 mins)","Steps":[{"descriptionHtml":"Head \u003Cb\u003Esouth\u003C\/b\u003E on \u003Cb\u003EShivaji Rd\u003C\/b\u003E toward \u003Cb\u003ELaxmi Rd\u003C\/b\u003E","Distance":{"meters":119,"html":"0.1\u0026nbsp;km"},"Duration":{"seconds":11,"html":"11 secs"},"Point":{"coordinates":[73.856230,18.516700,0]},"polylineIndex":0},{"descriptionHtml":"Turn \u003Cb\u003Eright\u003C\/b\u003E at \u003Cb\u003ELaxmi Rd\u003C\/b\u003E","Distance":{"meters":1349,"html":"1.3\u0026nbsp;km"},"Duration":{"seconds":177,"html":"2 mins"},"Point":{"coordinates":[73.856270,18.515630,0]},"polylineIndex":2},{"descriptionHtml":"Continue on \u003Cb\u003ESambhaji Bridge\u003C\/b\u003E","Distance":{"meters":11,"html":"11\u0026nbsp;m"},"Duration":{"seconds":26,"html":"26 secs"},"Point":{"coordinates":[73.843990,18.512920,0]},"polylineIndex":12},{"descriptionHtml":"Slight \u003Cb\u003Eleft\u003C\/b\u003E at \u003Cb\u003EN C Kelkar Rd\u003C\/b\u003E","Distance":{"meters":33,"html":"33\u0026nbsp;m"},"Duration":{"seconds":42,"html":"42 secs"},"Point":{"coordinates":[73.843880,18.512920,0]},"polylineIndex":14},{"descriptionHtml":"Turn \u003Cb\u003Eright\u003C\/b\u003E at \u003Cb\u003EFergusson College Rd\/\u003Cwbr\/\u003ESambhaji Bridge\u003C\/b\u003E","Distance":{"meters":228,"html":"0.2\u0026nbsp;km"},"Duration":{"seconds":33,"html":"33 secs"},"Point":{"coordinates":[73.843600,18.512860,0]},"polylineIndex":17},{"descriptionHtml":"Turn \u003Cb\u003Eleft\u003C\/b\u003E at \u003Cb\u003EKarve Rd\u003C\/b\u003E","Distance":{"meters":1759,"html":"1.8\u0026nbsp;km"},"Duration":{"seconds":159,"html":"2 mins"},"Point":{"coordinates":[73.842330,18.514500,0]},"polylineIndex":20},{"descriptionHtml":"Slight \u003Cb\u003Eright\u003C\/b\u003E at \u003Cb\u003EFly Over\u003C\/b\u003E","Distance":{"meters":431,"html":"0.4\u0026nbsp;km"},"Duration":{"seconds":73,"html":"1 min"},"Point":{"coordinates":[73.827820,18.506870,0]},"polylineIndex":28},{"descriptionHtml":"Continue on \u003Cb\u003EPaud Rd\u003C\/b\u003E","Distance":{"meters":4164,"html":"4.2\u0026nbsp;km"},"Duration":{"seconds":379,"html":"6 mins"},"Point":{"coordinates":[73.824140,18.506480,0]},"polylineIndex":35},{"descriptionHtml":"Turn \u003Cb\u003Eleft\u003C\/b\u003E toward \u003Cb\u003EMumbai Pune Bypass Rd\u003C\/b\u003E","Distance":{"meters":616,"html":"0.6\u0026nbsp;km"},"Duration":{"seconds":51,"html":"51 secs"},"Point":{"coordinates":[73.787850,18.507230,0]},"polylineIndex":64},{"descriptionHtml":"Sharp \u003Cb\u003Eleft\u003C\/b\u003E at \u003Cb\u003EMumbai Pune Bypass Rd\u003C\/b\u003E","Distance":{"meters":20716,"html":"20.7\u0026nbsp;km"},"Duration":{"seconds":1156,"html":"19 mins"},"Point":{"coordinates":[73.792390,18.504530,0]},"polylineIndex":74},{"descriptionHtml":"Take the ramp to \u003Cb\u003EMumbai Pune Express Way\u003C\/b\u003E","Distance":{"meters":540,"html":"0.5\u0026nbsp;km"},"Duration":{"seconds":33,"html":"33 secs"},"Point":{"coordinates":[73.730550,18.660070,0]},"polylineIndex":137},{"descriptionHtml":"Continue straight onto \u003Cb\u003EMumbai Pune Express Way\u003C\/b\u003E","Distance":{"meters":94048,"html":"94.0\u0026nbsp;km"},"Duration":{"seconds":4309,"html":"1 hour 12 mins"},"Point":{"coordinates":[73.726530,18.662660,0]},"polylineIndex":143},{"descriptionHtml":"Continue on \u003Cb\u003ESion - Panvel Express Hwy\u003C\/b\u003E","Distance":{"meters":7297,"html":"7.3\u0026nbsp;km"},"Duration":{"seconds":820,"html":"13 mins"},"Point":{"coordinates":[73.102830,19.020270,0]},"polylineIndex":535},{"descriptionHtml":"Slight \u003Cb\u003Eleft\u003C\/b\u003E toward \u003Cb\u003ESion - Panvel Express Hwy\u003C\/b\u003E","Distance":{"meters":884,"html":"0.9\u0026nbsp;km"},"Duration":{"seconds":60,"html":"1 min"},"Point":{"coordinates":[73.045150,19.022840,0]},"polylineIndex":560},{"descriptionHtml":"Slight \u003Cb\u003Eleft\u003C\/b\u003E at \u003Cb\u003ESion - Panvel Express Hwy\u003C\/b\u003E","Distance":{"meters":4816,"html":"4.8\u0026nbsp;km"},"Duration":{"seconds":657,"html":"10 mins"},"Point":{"coordinates":[73.037750,19.025830,0]},"polylineIndex":567},{"descriptionHtml":"Take the ramp onto \u003Cb\u003ESion - Panvel Express Hwy\u003C\/b\u003E","Distance":{"meters":5089,"html":"5.1\u0026nbsp;km"},"Duration":{"seconds":297,"html":"4 mins"},"Point":{"coordinates":[73.019100,19.061440,0]},"polylineIndex":588},{"descriptionHtml":"Continue on \u003Cb\u003EVashi Bridge\u003C\/b\u003E","Distance":{"meters":2524,"html":"2.5\u0026nbsp;km"},"Duration":{"seconds":161,"html":"2 mins"},"Point":{"coordinates":[72.978420,19.063410,0]},"polylineIndex":612},{"descriptionHtml":"Continue on \u003Cb\u003EYaswanth Rao Chavan Marg\u003C\/b\u003E","Distance":{"meters":4297,"html":"4.3\u0026nbsp;km"},"Duration":{"seconds":273,"html":"4 mins"},"Point":{"coordinates":[72.955190,19.057720,0]},"polylineIndex":616},{"descriptionHtml":"Continue on \u003Cb\u003EV N Purav Marg\u003C\/b\u003E \u003Cdiv class=\"google_note\"\u003EGo through 1 traffic circle\u003C\/div\u003E","Distance":{"meters":4086,"html":"4.1\u0026nbsp;km"},"Duration":{"seconds":334,"html":"5 mins"},"Point":{"coordinates":[72.918250,19.044520,0]},"polylineIndex":628},{"descriptionHtml":"Slight \u003Cb\u003Eleft\u003C\/b\u003E at \u003Cb\u003EEastern Express Hwy\/\u003Cwbr\/\u003ENH 3\/\u003Cwbr\/\u003EVasant Rao Naik Marg\u003C\/b\u003E \u003Cdiv class=\"google_note\"\u003EGo through 2 traffic circles\u003C\/div\u003E","Distance":{"meters":4374,"html":"4.4\u0026nbsp;km"},"Duration":{"seconds":377,"html":"6 mins"},"Point":{"coordinates":[72.882520,19.053570,0]},"polylineIndex":654},{"descriptionHtml":"At the traffic circle, take the \u003Cb\u003E2nd\u003C\/b\u003E exit onto \u003Cb\u003EH Adenwala Rd\u003C\/b\u003E","Distance":{"meters":761,"html":"0.8\u0026nbsp;km"},"Duration":{"seconds":87,"html":"1 min"},"Point":{"coordinates":[72.855890,19.027280,0]},"polylineIndex":677},{"descriptionHtml":"At the traffic circle, take the \u003Cb\u003E2nd\u003C\/b\u003E exit onto \u003Cb\u003ED.S. Barato Rd\u003C\/b\u003E \u003Cdiv class=\"google_note\"\u003EDestination will be on the right\u003C\/div\u003E","Distance":{"meters":250,"html":"0.2\u0026nbsp;km"},"Duration":{"seconds":46,"html":"46 secs"},"Point":{"coordinates":[72.854010,19.021070,0]},"polylineIndex":685}],"End":{"coordinates":[72.854486,19.019713,0]},"polylineEndIndex":692}],"Polyline":{"id":"route","points":"kp_pBm`xaMtEG??PdAnAvBjBvERbDBdFpCfd@z@rE`BvEFb@???T??NXC\\??wFpEoAj@??jDjDrApBjBpGtHlRlE|LdOd^~BrG??xBtG`A~DEnBKd@Uj@eAfA??s@v@_OlL{C`D}@dCKl@IjCZrHjAnJxAxH\\dMlAhD`CvCb@xEPt@zBpFTzBj@hKf@pNq@pFi@|GYpGeAhOAp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t@S`C[`M}@lSe@nR[bHk@z^]fHk@zFuBpk@SnBu@`RQhHB|@ZxAjA|C`WpWdCzEbAvC|B|I??v[jxBhAnJnChK??p]btAbA~CxEvQzPvr@bBtC|Yn^p@xANfAAhAQxAkEzV??eCpKQnC{@xGEtIOdD@~DLjCA^a@dBAj@GNm@PiLbMsFhFiDrDkChDaAhCqDhNqFxTwAdHe@pDMdUzAzc@PvLCdB??fBzDb@ZF\\Qn@~AtFjW`cAdAxChA~BdBbChAlA|DtDjD|B`MhDf@_@j@CXF`@h@?p@~PjKvz@tX`ErBdHnF??`AUl@@l@Rf@jA@v@zRhCtKhB??h@aBx@}@^Q`AOr@Nn@l@Yb@","levels":"BBB??@?????BBBB?BB?BB??????BB?@???BB??@??@???@????@?@??????@???BB???@????BB??@??@???@?@?@?A???@?@???@??????@??@????A??????@????????@????BB?@??BB?@????A?????@???@????@??A??@??????@????A???@?@?@??????A???????A??????????@?@????@??@???@??A???@??@???@???@??A??@??@???A??@????@???@?????A?????@??????A??@???@????????@????@???A??@??????@?????@?????A????@??@???????@??@???@????@??????@?@???@?@?????@??@????@??@?A??@???@??????@?????@?@???@???A???@???@??@???@?????@???@???@???@???@??A????@????A????@???@???A????@????@????A????????????????@??????BB????????A???@?????@??@?BB?@???BB@?????@???@????@???BB???@???????????@??@@??BB??BB???@??@???BB?????????@?????@???@????BB?????@???@???????????BB??????BB??@???B","numLevels":4,"zoomFactor":16}}}

Page 55: Advanced Android - GodSpeed

Use of Sensors

SensorManager mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);

mSensorManager.registerListener(mRotateView,SensorManager.SENSOR_ORIENTATION,SensorManager.SENSOR_DELAY_NORMAL);

Page 56: Advanced Android - GodSpeed

Use of Sensors

public class RotateView implements SensorListener {private int mHeading = 0; public abstract void onSensorChanged(int sensor, float[]

values){ // Rotation around Z Index mHeading= values[0]; //Rotate Map here } public abstract void onAccuracyChanged(int sensor, int

accuracy){ }

}

Page 57: Advanced Android - GodSpeed

Use of ViewGroup

• ViewGroup is used in GodSpeed to achieve rotation of map

• ViewGroup also implements SensorListener• Logic

o When ever the onSensorChanged method is called, it records the rotation and invalidates the view

o This calls dispatchDraw(Canvas canvas). Now as we have access to the canvas we can rotate the canvas.

Page 58: Advanced Android - GodSpeed

Use of ViewGroup

Page 59: Advanced Android - GodSpeed

Questions?

?