270 likes | 425 Views
PLAT-282T. File type associations and AutoPlay. Anshul Rawat Principal Program Manager Lead Microsoft Corporation. Agenda. Overview of file type / protocol association and AutoPlay How your Metro style apps can participate You’ll leave with examples of how to
E N D
PLAT-282T File type associations and AutoPlay Anshul Rawat Principal Program Manager Lead Microsoft Corporation
Agenda • Overview of file type / protocol association and AutoPlay • How your Metro style apps can participate You’ll leave with examples of how to • Participate in the file type / protocol association system • Participate in the AutoPlay system
The Windows 8 file type, protocol and device association model puts the user in control while removing the burden from the app.
demo File association and AutoPlay in action Choosing default handlers
User experience model • The user is always in control • One common UI across Metro style apps and desktop apps • Consistent experience between file association and AutoPlay
demo Registering a Metro style app to handle file type / protocol associations & AutoPlay
Registration via manifest • Declare your supported file types and/or protocols • Add AutoPlay Content or Device declarations to respond to device events • Remember: New scenarios (NFC) can take advantage of these registrations
Responding to activation events • File access is through the trust broker • Persist StorageFile items that you need to access across sessions • Responding to activation events from AutoPlay has been simplified for Metro style apps • AutoPlay will now call your app with your verb and the root folder of the device content
Receiving a StorageFile Item • // Receive activation. • function onActivatedHandler(eventArgs) { • if (eventArgs.kind == Windows.ApplicationModel.Activation.ActivationKind.file) { • … • sdkSample.displayStatus("File activation received. The number of files received is " + eventArgs.files.size + ". The first received file is " + eventArgs.files[0].name + ".");
Persisting access to a StorageFile item StorageApplicationPermissions.mostRecentlyUsedList.add • // From FileAccess SDK sample • function scenario5AddToMRU() { • //Adding sample.txt in the MRU list • if(sampleFile != null) { • mruToken = Windows.Storage.AccessCache.StorageApplicationPermissions.mostRecentlyUsedList.add(sampleFile, sampleFile.fileName); • id("scenario5Output").innerHTML = '<p>The file <b>sample.txt</b> was added into MRU list and a token was stored.</p>'; • } • }
Receiving Items from AutoPlay • // Receive activation. • function onActivatedHandler(eventArgs) { • if (eventArgs.kind == Windows.ApplicationModel.Activation.ActivationKind.file) { • … • sdkSample.displayStatus("AutoPlay content received. The user selected the " + eventArgs.verb+ " task. The folder containing the items is " + eventArgs.files[0].name + ".");
demo Launcher API, SDK sample
New launcher APIs • Basic usage – launch a file • Windows.System.Launcher.launchDefaultProgramForFile(file); • Basic usage – launch a protocol • Windows.System.Launcher.launchDefaultProgram(uri); • Force OpenWith to appear (for use in a secondary action) • Windows.System.Launcher.launchDefaultProgramForFile(file, Windows.System.ProgramPickerOptions.none, anchor);
How should my app manage defaults for file types and protocols?
Guidelines for existing apps • You don’t need to check to see if your app is the default • You don’t need to set your app as the default • You don’t need to manage defaults for file types and protocols from within your app • You could integrate with the control panel instead
Recap • How to get your app in the Open With & AutoPlay UI • How to respond to activation in your apps • How to launch other files and protocols • What the model means for existing apps
Related sessions • PLAT-894T: Seamlessly interacting with web and local data • PLAT-891T: Using files: accessing, searching, and acting on files • HW-269T: Designing systems and developing drivers for NFC
Further reading and documentation • Association Launching SDK sample • FileAccess SDK sample • Whitepaper for implementing file type / protocol associations • Whitepapers for implementing AutoPlay (JS, C#/VB/C++) • Questions? • Please visit the forums on the Windows Dev Center at http://forums.dev.windows.com • For best response, please include the Build Session # in the title of your post
thank you Feedback and questions http://forums.dev.windows.com Session feedbackhttp://bldw.in/SessionFeedback
© 2011 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.