1 / 32

Windows Phone 8 Tips & Tricks for Developers

Windows Phone 8 Tips & Tricks for Developers. Sascha Corti, Microsoft Switzerland Technical Evangelist sascha.corti@microsoft.com | techpreacher.corti.com | @ techpreacher. #shape13. Agenda. Updating Apps from WP 7.1 to WP 8 App Localization The Multilingual App Toolkit Proximity: NFC

pennie
Download Presentation

Windows Phone 8 Tips & Tricks for Developers

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. Windows Phone 8Tips & Tricks for Developers Sascha Corti, Microsoft SwitzerlandTechnical Evangelistsascha.corti@microsoft.com | techpreacher.corti.com | @techpreacher #shape13

  2. Agenda Updating Apps from WP 7.1 to WP 8 App Localization The Multilingual App Toolkit Proximity: NFC Maps and Location Running in the Background Fast App Resume done right! Next Session: Apps Targeting Win8 & WP8

  3. Updating your Apps from WP7.1 to WP8

  4. Compile in the Cloud Moving to CoreCLR brings Native Image Generator (NGEN) Expensive and Time consuming on Device. Compile in the cloud NGEN’s your Code when you submit Code in XAP is NGEN’d and XAP updated with Compiled Code. What about existing Apps? 7.5 apps are NGEN’d so Windows Phone 8 gets Compiled Version. Original 7.5 apps is kept for Download to 7.5 Devices Windows Phone 7.5Marketplace Windows Phone 8Marketplace

  5. WP 7.1 and 8 Apps in the Store “My App” Store Listing Pitfalls Version Number of the WP 8 XAP must be higher than WP 7.1 XAP. Updating WP 7.1 XAP with WP 8 XAP Removes WP 7.1 Support. OS 7.1 OS 8.0 XAP-2 WVGA XAP-1 XAP-3 WXGA XAP-4 720p OS 7.1 Metadata OS 8.0Metadata In App Products

  6. WP 7.1 and 8 Apps in the Store

  7. Two Top Level Projects Duplicate WP7.1 Project in Solution. Rename to “xyz WP7” and “xyz WP8”. Update WP8 Project. 2 Separate Code Bases.

  8. Linked Source Code Files Remove Classes / UI from WP8 Solution. Add Existing Files from WP7 as Link. Don’t link App.xaml(.cs), WMAppManifest.xml 2 Separate Code Baseswith shared Files.

  9. Compile-Time Adaptation Define Custom Compilation Symbol for WP8 Project Use Compiler Directives to distinguish Does not exist for XAML  #if WP8 // Code to run in WP8 #else // Code to run in WP7 #endif

  10. Async Pattern in WP7.1 App Add NuGet Package: “Microsoft.Bcl.Async”. Include Prerelease Packages in Search.

  11. demo Maintaining both WP7 and WP8 Projects.

  12. Shared Assemblies Add Portable Class Library to Solution Reference from both Projects Very useful in MVVM based Projects. WP7.1 Project WP8 Project View View Portable Class Library ViewModel Business Logic

  13. Two Branches Of Same App Project Create Branch off WP7 Project Keep both Branches, Merge WP8 Changes Selectively to keep updating WP7 Project

  14. App Localization Multilingual App Toolkit for Visual Studio 2012

  15. Multilingual App Toolkit for VS 2012 Free Download http://corti.ch/vs2012-mat Multilingual Editor Works with XLIFF Format Files Can use Bing Translation State per Resource & Language for Teams Links How to use the Multilingual App Toolkit

  16. Testing Multilingual Apps Multiple Emulator Images Different Language/Locale Settings Dark/Light Color Themes Settings not Persisted 

  17. demo Multilingual Apps

  18. Proximity: NFC And some Bluetooth

  19. Near Field Communications Provides Connectivity Between Devices that are very close together (within 3-4 Centimeters) Between Devices and unpowered NFC Chips Transfer of a Message or Byte Stream Max Data Transfer Rate 424 kbits/s. Typical Data Transfer Rates from 30 kbits/s to 60 kbits/s NFC can be used to initiate a connection implemented using Bluetooth or WiFi Extends the PeerFinder to allow an application to set up a StreamSocket between two devices The ID_CAP_PROXIMITY capability must be enabled for the application

  20. Near Field Communications Options Tag to App App to App App to Device

  21. Listening for Incoming NFC Messages ProximityDevice device = ProximityDevice.GetDefault(); // Register Event Handlers for NFC Detection / Departure device.DeviceArrived += device_DeviceArrived; device.DeviceDeparted += device_DeviceDeparted; // Register Event Handlers for Various Incoming NFC Message Formats device.SubscribeForMessage("WriteableTag", WriteableTagHandler); device.SubscribeForMessage("Windows.MySubType", SubTypeHandler); device.SubscribeForMessage("WindowsUri", WindowsUriHandler); device.SubscribeForMessage("WindowsMime", WindowsMimeHandler); device.SubscribeForMessage("NDEF", NDEFHandler); //Writable Size Tag received privatevoidWriteableTagHandler(ProximityDevice sender, ProximityMessage message) { varWritableSize = System.BitConverter.ToInt32(message.Data.ToArray(), 0); Dispatcher.BeginInvoke(() => { TagSize.Text = WritableSize.ToString() + " Bytes"; }); }

  22. http://ndef.codeplex.com/ Publishing NFC Messages //create a NDEF message varndefRecord = newNdefTextRecord { Text = NfcMessage.Text, LanguageCode = CultureInfo.CurrentCulture.TwoLetterISOLanguageName }; varndefMessage = newNdefMessage { ndefRecord }; //publish binary NDEF message. longpublishId= device.PublishBinaryMessage("NDEF:WriteTag", ndefMessage.ToByteArray().AsBuffer(), publishHandler); privatevoidpublishHandler(ProximityDevice sender, longmessageId) { // Tag has been written to. Stop publishing. device.StopPublishingMessage(publishId); publishId = null; }

  23. Proximity Tapper Select Emulator(s) Tap virtual NFC Send Message(s) http://proximitytapper.codeplex.com/

  24. demo Sending Data via NFC from an App

  25. Maps and Location And their ability to run in the Background!

  26. Multitasking Background Location Nokia Map Technology Global NAVTEQ Map data Offline map support, Turn-by-Turn Directions For Developers Allow for Location Apps to continue running in the Background New Nokia Map Control (Bing Maps control supported but deprecated) Converge with Windows 8 / Managed and Native Code Windows Phone Map Services Geocoding: Latitude,Longitudeto Address Reverse Geocoding: Address to Latitude,Longitude Routing: RouteQuery, Route, RouteLeg, RouteManeuver Four Cartographic Map Modes

  27. Built-In Map Tasks MapTask Launch Map App. Can specify Center, Point to show, Zoom Level etc. MapsDirectionTask Start Turn-by-Turn Directions. Missing Parameters substituted by user’s Location. MapsDownloaderTask Download Map Data for Offline Use.

  28. Single Location Request publicasyncTask<Geocoordinate> GetSinglePositionAsync() { Geolocatorgeolocator = new Geolocator();  geolocator.DesiredAccuracyInMeters= 10; Geopositiongeoposition = awaitgeolocator.GetGeopositionAsync(TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(30)); return geoposition.Coordinate; } Tracking In Background LocactionTracking WMAppManifest.xml <DefaultTaskName="_default"NavigationPage="SearchPage.xaml"> <BackgroundExecution> <ExecutionTypeName="LocationTracking"/> </BackgroundExecution> </DefaultTask> voidgeolocator_PositionChanged(Geolocator sender, PositionChangedEventArgsargs){ Dispatcher.BeginInvoke(() =>{txtLat.Text= args.Position.Coordinate.Latitude.ToString("0.00");txtLon.Text= args.Position.Coordinate.Longitude.ToString("0.00"); });} Attach/Detach Event Handler to Start/Stop Actively listen for location change events

  29. Background Execution: Resources App has access to Location, Sensors Audio / Speech Network, Storage ShellToast and ShellTile.Update Users can Close the Running App Disable BG Functionality per App App runs in Background until App stops tracking Location Another Location Tracking App moves to Background User disables Location Services 4 hours without bringing the App to the Foreground Battery Saver ON / Low memory CPU allocation capped at 10%

  30. demo Building a Map App with Background Location Tracking

  31. Developer Resources Streamed sessions from //build/ conference http://channel9.msdn.com/Events/Build/2012 New Phone Developer Center https://dev.windowsphone.com/en-us/dashboard All about Windows Phone http://www.windowsphone.com Windows Phone Developer Learning http://msdn.microsoft.com/en-us/library/windowsphone/develop Windows Phone 8 SDK free Download http://dev.windowsphone.com

More Related