Download presentation
Presentation is loading. Please wait.
Published byDerick Wheeler Modified over 9 years ago
1
Windows Phone 8 Tips & Tricks for Developers Sascha Corti, Microsoft Switzerland Technical Evangelist sascha.corti@microsoft.com | techpreacher.corti.com | @techpreacher #shape13
2
Agenda
3
Updating your Apps from WP7.1 to WP8
5
“My App” Store Listing In App Products OS 7.1 Metadata OS 8.0 Metadata
7
Duplicate WP7.1 Project in Solution. Rename to “xyz WP7” and “xyz WP8”. Update WP8 Project. 2 Separate Code Bases.
8
Remove Classes / UI from WP8 Solution. Add Existing Files from WP7 as Link. Don’t link App.xaml(.cs), WMAppManifest.xml 2 Separate Code Bases with shared Files.
9
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
Add NuGet Package: “Microsoft.Bcl.Async”. Include Prerelease Packages in Search.
11
demo Maintaining both WP7 and WP8 Projects.
12
Add Portable Class Library to Solution Reference from both Projects Very useful in MVVM based Projects. Portable Class Library ViewModel Business Logic WP7.1 Project View WP8 Project View
13
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
17
demo Multilingual Apps
18
Proximity: NFC And some Bluetooth
20
App to App Tag to App App to Device
21
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 private void WriteableTagHandler(ProximityDevice sender, ProximityMessage message) { var WritableSize = System.BitConverter.ToInt32(message.Data.ToArray(), 0); Dispatcher.BeginInvoke(() => { TagSize.Text = WritableSize.ToString() + " Bytes"; }); }
22
//create a NDEF message var ndefRecord = new NdefTextRecord { Text = NfcMessage.Text, LanguageCode = CultureInfo.CurrentCulture.TwoLetterISOLanguageName }; var ndefMessage = new NdefMessage { ndefRecord }; //publish binary NDEF message. long publishId = device.PublishBinaryMessage("NDEF:WriteTag", ndefMessage.ToByteArray().AsBuffer(), publishHandler); private void publishHandler(ProximityDevice sender, long messageId) { // Tag has been written to. Stop publishing. device.StopPublishingMessage(publishId); publishId = null; } http://ndef.codeplex.com/
23
Select Emulator(s) Tap virtual NFC Send Message(s)
24
demo Sending Data via NFC from an App
25
Maps and Location And their ability to run in the Background!
28
Single Location Request Locaction Tracking Tracking In Background public async Task GetSinglePositionAsync() { Geolocator geolocator = new Geolocator(); geolocator.DesiredAccuracyInMeters = 10; Geoposition geoposition = await geolocator.GetGeopositionAsync(TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(30)); return geoposition.Coordinate; } void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args) { Dispatcher.BeginInvoke(() => { txtLat.Text = args.Position.Coordinate.Latitude.ToString("0.00"); txtLon.Text = args.Position.Coordinate.Longitude.ToString("0.00"); }); } WMAppManifest.xml Actively listen for location change eventsAttach/Detach Event Handler to Start/Stop
29
CPU allocation capped at 10%
30
demo Building a Map App with Background Location Tracking
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.