Maarten Struys Windows Mobile Evangelist Alten-PTS WMB301.

31

Transcript of Maarten Struys Windows Mobile Evangelist Alten-PTS WMB301.

Page 1: Maarten Struys Windows Mobile Evangelist Alten-PTS WMB301.
Page 2: Maarten Struys Windows Mobile Evangelist Alten-PTS WMB301.

Creating Location-Aware Applications for Windows Mobile Devices

Maarten StruysWindows Mobile EvangelistAlten-PTSWMB301

Page 3: Maarten Struys Windows Mobile Evangelist Alten-PTS WMB301.

Agenda

IntroductionRetrieving Location Information

Making use of Cell TowersMaking use of IP AddressMaking use of GPS

Developing Location-Aware applicationsWeb Services, Location, Windows Mobile and you

Conclusion

Page 4: Maarten Struys Windows Mobile Evangelist Alten-PTS WMB301.

IntroductionLocation-Aware Applications

Technology offers a huge potentialAll about Positioning and Content

More than drawing maps inside applications

Navigation softwareLocalized news, weather, traffic, sportsDevice can tell others where it is

Tracking people or carsSocial Networking

Page 5: Maarten Struys Windows Mobile Evangelist Alten-PTS WMB301.

IntroductionLocation and Windows Mobile

Most Windows Mobile Devices are phonesUse Cell Tower information for fast location fetch

Make use of existing lookup functionality

Most Windows Mobile Devices have WIFIUse access point for accurate, fast location fetch

Make use of Geo IP lookup services

More devices ship with built-in GPS hardwareUse GPS Intermediate Driver to retrieve locations

Managed wrappers available in Windows Mobile SDKs

Page 6: Maarten Struys Windows Mobile Evangelist Alten-PTS WMB301.

Location RetrievalCell Tower

Fast but relatively inaccurate Location FetchAccuracy higher in densely populated areas

Works if there is phone coverageRetrieve Cell Tower Information through RIL

RIL_Initialize(); RIL_Deinitialize();RIL_CellTowerLookup();

Pass Cell Tower Information to a Lookup Servicehttp://www.codeproject.com/KB/mobile/DeepCast.aspxby “Acoustic”

Page 7: Maarten Struys Windows Mobile Evangelist Alten-PTS WMB301.

Retrieving Location Using Cell Towerdemo

Page 8: Maarten Struys Windows Mobile Evangelist Alten-PTS WMB301.

Location RetrievalIP Address Lookup

Fast and reasonably accurate Location FetchAccuracy higher in densely populated areas

Works if there is Wifi coveragePass IP number to a Lookup Service

Page 9: Maarten Struys Windows Mobile Evangelist Alten-PTS WMB301.

Retrieving Location Using IP Numberdemo

Page 10: Maarten Struys Windows Mobile Evangelist Alten-PTS WMB301.

Location RetrievalGPS

Initial reading might be slow but very accurate Location FetchDoes not work well (if at all) inside buildingsLocation information available without additional lookup servicesEasy access through GPS Intermediate Driver

Windows Mobile 5 and Windows Mobile 6

Page 11: Maarten Struys Windows Mobile Evangelist Alten-PTS WMB301.

Location RetrievalGPS Intermediate Driver

Allows “high level” access of the GPS Hardware by using the “parsed API”

No need to parse NMEA strings yourselfFor applications, the GPS Intermediate Driver looks like the physical GPS hardwareFor the GPS hardware, the GPS Intermediate Driver is the single client using itLocation changes will be delivered event driven on a separate thread

Page 12: Maarten Struys Windows Mobile Evangelist Alten-PTS WMB301.

Location RetrievalGPSID and Managed Applications

Microsoft.WindowsMobile.Samples.Location

Page 13: Maarten Struys Windows Mobile Evangelist Alten-PTS WMB301.

Location RetrievalTesting GPS readings with FakeGPS

Allows testing location aware applications without having GPS hardware on the deviceAlso ideal for poor satellite receptionRequires no changes to your applicationFakes data received by the GPS APIs\Program Files\FakeGPS\GPSFiles

Contains NMEA dataYou can record your own NMEA data

Page 14: Maarten Struys Windows Mobile Evangelist Alten-PTS WMB301.

Receiving Location through GPSdemo

Page 15: Maarten Struys Windows Mobile Evangelist Alten-PTS WMB301.

Location Aware ApplicationsMake them independent of Location Retrieval

Different Location Retrieval methods have different accuraciesThe easiest to in your application is abstracting location retrieval

Use a Class FactoryRetrieve Location readings through an InterfaceApplication is only interested in Lat/Long readings, not where they come from

Page 16: Maarten Struys Windows Mobile Evangelist Alten-PTS WMB301.

Location Aware ApplicationsDifferent categories of applications

Line-of-Business ApplicationsFleet tracking + Route planning

Device publishes its location

Consumer ApplicationsOften a Collaboration between the Cloud & DeviceSmart Client Application (e.g., pictures + location)Location Aware bloggingSocial NetworkingFinding Friends

Page 17: Maarten Struys Windows Mobile Evangelist Alten-PTS WMB301.

Location Aware ApplicationsSample Applications

Live Search MobileGoogle MapsUpdate Twitter Status and automatically add location (+ optional link to a map)Share information with friends through Fire EagleAll kinds of Windows Live Services

Virtual Earth alone has lots of different services

Page 18: Maarten Struys Windows Mobile Evangelist Alten-PTS WMB301.

Sample: Updating Twitter Status

string user = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes (Properties.Resources.TwitterUserName + ":" + Properties.Resources.TwitterPassword));StringBuilder sb = new StringBuilder("status=");sb.Append(locationInfo);if (additionalInfo != string.Empty){ sb.Append(" - "); sb.Append(additionalInfo);}byte[] data = Encoding.ASCII.GetBytes(sb.ToString());

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(TwitterStatusUpdateURI);request.Method = "POST";request.Headers.Add("Authorization", "Basic " + user);request.ContentType = "application/x-www-form-urlencoded";request.ContentLength = data.Length;Stream reqStream = request.GetRequestStream();reqStream.Write(data, 0, data.Length);reqStream.Close();

Page 19: Maarten Struys Windows Mobile Evangelist Alten-PTS WMB301.

Location Aware ApplicationsRetrieving Maps through Virtual Earth

Imagery ServiceMaps & Imagery for Mobile Devices

Search ServiceQueries to find keywords or locations

Geocode ServiceAddress to LatLong and LatLong to Address

Route ServiceGet directions and traffic info

Page 20: Maarten Struys Windows Mobile Evangelist Alten-PTS WMB301.

Sample: Displaying VE Maps

public Image GetMap(double latitude, double longitude){ // Set the location of the requested image mapUriRequest.Center = new VEImageryService.Location(); mapUriRequest.Center.Latitude = latitude; mapUriRequest.Center.Longitude = longitude; mapUriRequest.Center.LongitudeSpecified = true; mapUriRequest.Center.LatitudeSpecified = true;

// Retrieve a map (jpg) through a URL, provided by Virtual Earth MapUriResponse mapUriResponse = imageryService.GetMapUri(mapUriRequest); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(mapUriResponse.Uri); HttpWebResponse response = (HttpWebResponse)request.GetResponse();

Image img = new Bitmap(response.GetResponseStream()); response.Close();

return img;}

Page 21: Maarten Struys Windows Mobile Evangelist Alten-PTS WMB301.

Location Aware ApplicationsRetrieving information through Live Search

Consistent Web Service to retrieve all kinds of information

MobileWebAdvertisementsImagesPhoneBook

Learn how to access one source of information and you know how to access them all

Page 22: Maarten Struys Windows Mobile Evangelist Alten-PTS WMB301.

Sample: Using Live Search

private void button1_Click(object sender, EventArgs e){ using (LiveSearchService service = new LiveSearchService()) { SearchRequest request = new SearchRequest(); request.AppId = Properties.Resources.LiveSearchAppID; request.Query = searchQuery; request.Sources = new SourceType[] {SourceType.MobileWeb }; SearchResponse response = service.Search(request);

foreach (MobileWebResult r in response.MobileWeb.Results) { listView1.Items.Add(new ListViewItem(r.Title)); } }}

Page 23: Maarten Struys Windows Mobile Evangelist Alten-PTS WMB301.

A Location Aware Sample Applicationdemo

Page 24: Maarten Struys Windows Mobile Evangelist Alten-PTS WMB301.

Summary

There are several ways to retrieve Location Information

Cell Tower Lookup; IP Number Lookup; GPSAdding Location to Windows Mobile Applications extend application richnessThink Out of the Box

Make use of Web Services / Web Apps to increase the functionality of Windows Mobile Applications

Great opportunities for Business- and Consumer- oriented applications

Page 25: Maarten Struys Windows Mobile Evangelist Alten-PTS WMB301.

question & answer

Page 26: Maarten Struys Windows Mobile Evangelist Alten-PTS WMB301.

www.microsoft.com/teched

Sessions On-Demand & Community

http://microsoft.com/technet

Resources for IT Professionals

http://microsoft.com/msdn

Resources for Developers

www.microsoft.com/learningMicrosoft Certification and Training Resources

www.microsoft.com/learning

Microsoft Certification & Training Resources

Resources

Page 27: Maarten Struys Windows Mobile Evangelist Alten-PTS WMB301.

Related Content

DAT324 WiE: Building Location-Aware Services with Microsoft SQL ServerFri 5/15 | 1:00 PM-2:15 PM | Room 402

UNC305: Enabling Anywhere Access with Microsoft Office Communications Server 2007Wed 5/13 | 4:30 PM-5:45 PM | Room 502B

WMB401: Adding WCF to Windows Mobile ApplicationsThu 5/14 | 4:30 PM-5:45 PM | Room 511

WMB01-HOL Building Real-World-Ready Applications for Windows Mobile with the Microsoft Device Emulator 3.0 and the Device Emulator Manager Automation API

Page 28: Maarten Struys Windows Mobile Evangelist Alten-PTS WMB301.

Windows Mobile® ResourcesTechNet TechCenter – System Center Mobile Device Manager 2008 http://technet.microsoft.com/scmdm

TechNet TechCenter – Windows Mobile http://technet.microsoft.com/windowsmobile

MSDN Center – Windows Mobilehttp://msdn.microsoft.com/windowsmobile

Webcasts and Podcasts for IT – Windows Mobilehttp://www.microsoft.com/events/series/msecmobility.aspx

General Information – Windows Mobilehttp://www.windowsmobile.com

General Information – System Center Mobile Device Manager 2008http://www.windowsmobile.com/mobiledevicemanager

Windows Marketplace Developer Portalhttp://developer.windowsmobile.com

Page 29: Maarten Struys Windows Mobile Evangelist Alten-PTS WMB301.

Windows Mobile® is giving away Blackjack IIs !

Stop by the Windows Mobile Technical Learning Center to learn how to enter

Page 30: Maarten Struys Windows Mobile Evangelist Alten-PTS WMB301.

Complete an evaluation on CommNet and enter to win!

Page 31: Maarten Struys Windows Mobile Evangelist Alten-PTS WMB301.

© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS,

IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.