easy programmatic access to the file system, file type associations, and new system ui controls for...
TRANSCRIPT
![Page 1: Easy programmatic access to the file system, file type associations, and new system UI controls for opening files Simple integration with the file](https://reader035.vdocument.in/reader035/viewer/2022062518/5697bf861a28abf838c87ff5/html5/thumbnails/1.jpg)
www.buildwindows.com
APP-398T
How to declare your app’s capabilities
Jeff JohnsonDirector of DevelopmentWindows User ExperienceMicrosoft Corporation
![Page 2: Easy programmatic access to the file system, file type associations, and new system UI controls for opening files Simple integration with the file](https://reader035.vdocument.in/reader035/viewer/2022062518/5697bf861a28abf838c87ff5/html5/thumbnails/2.jpg)
www.buildwindows.com
Agenda
• Explore the capability model for Metro style apps• Best practices for accessing the file system and
devices• New features for working with capabilities
You’ll leave with examples of how to• Identify and add any required capabilities• Incorporate programmatic file access in your app
![Page 3: Easy programmatic access to the file system, file type associations, and new system UI controls for opening files Simple integration with the file](https://reader035.vdocument.in/reader035/viewer/2022062518/5697bf861a28abf838c87ff5/html5/thumbnails/3.jpg)
Capabilities provide access to system resources and connected devices, and are declared in the
package manifest.
![Page 4: Easy programmatic access to the file system, file type associations, and new system UI controls for opening files Simple integration with the file](https://reader035.vdocument.in/reader035/viewer/2022062518/5697bf861a28abf838c87ff5/html5/thumbnails/4.jpg)
www.buildwindows.com
Capabilities enable…
• Easy programmatic access to the file system, file type associations, and new system UI controls for opening files
• Simple integration with the file system and connected devices like webcams and location sensors
• New declarative access model for PC resources that shows users app capabilities prior to purchase
![Page 5: Easy programmatic access to the file system, file type associations, and new system UI controls for opening files Simple integration with the file](https://reader035.vdocument.in/reader035/viewer/2022062518/5697bf861a28abf838c87ff5/html5/thumbnails/5.jpg)
Capabilities in the Store
![Page 6: Easy programmatic access to the file system, file type associations, and new system UI controls for opening files Simple integration with the file](https://reader035.vdocument.in/reader035/viewer/2022062518/5697bf861a28abf838c87ff5/html5/thumbnails/6.jpg)
www.buildwindows.com
• Users are notified about which capabilities an app declares as part of their app Store acquisition • Ensure that requested capabilities match customer
expectations
• Users can also easily enable or disable access to sensitive devices via the Settings Charm for each app
• File type associations are also declarative, and users can select their preferred applications for each file type
Keeping the user in control
![Page 7: Easy programmatic access to the file system, file type associations, and new system UI controls for opening files Simple integration with the file](https://reader035.vdocument.in/reader035/viewer/2022062518/5697bf861a28abf838c87ff5/html5/thumbnails/7.jpg)
Suspect capabilities
This app could use your:LocationDocuments LibraryWebcamMicrophone
![Page 8: Easy programmatic access to the file system, file type associations, and new system UI controls for opening files Simple integration with the file](https://reader035.vdocument.in/reader035/viewer/2022062518/5697bf861a28abf838c87ff5/html5/thumbnails/8.jpg)
www.buildwindows.com
Invocation & Contracts
Windows Runtime environment
AppContainer – Signed + Validated
process.exe
WinRT
APIs
Core OS
Direct API calls
Filtered to declared capabilities in the package manifest
![Page 9: Easy programmatic access to the file system, file type associations, and new system UI controls for opening files Simple integration with the file](https://reader035.vdocument.in/reader035/viewer/2022062518/5697bf861a28abf838c87ff5/html5/thumbnails/9.jpg)
www.buildwindows.com
Metro style app packages
• A package contains each Metro style app
• Delivered by a single trusted store
• Easy for users to install and uninstall
• Explicitly declares the app interface points used• Capabilities• Devices• File type associations• App contracts
![Page 10: Easy programmatic access to the file system, file type associations, and new system UI controls for opening files Simple integration with the file](https://reader035.vdocument.in/reader035/viewer/2022062518/5697bf861a28abf838c87ff5/html5/thumbnails/10.jpg)
www.buildwindows.com
File capabilities
• musicLibrary• picturesLibrary• videoLibrary• documentsLibrary• removableStorage
![Page 11: Easy programmatic access to the file system, file type associations, and new system UI controls for opening files Simple integration with the file](https://reader035.vdocument.in/reader035/viewer/2022062518/5697bf861a28abf838c87ff5/html5/thumbnails/11.jpg)
www.buildwindows.com
Device capabilities
• webcam• microphone• location• sms• proximity• extensible to new device classes…
![Page 12: Easy programmatic access to the file system, file type associations, and new system UI controls for opening files Simple integration with the file](https://reader035.vdocument.in/reader035/viewer/2022062518/5697bf861a28abf838c87ff5/html5/thumbnails/12.jpg)
www.buildwindows.com
Network & identity capabilities
• Network capabilities• internetClient• internetClientServer• privateNetworkClientServer
• Identity capabilities• defaultWindowsCredentials• sharedUserCertificates
![Page 13: Easy programmatic access to the file system, file type associations, and new system UI controls for opening files Simple integration with the file](https://reader035.vdocument.in/reader035/viewer/2022062518/5697bf861a28abf838c87ff5/html5/thumbnails/13.jpg)
Manifest Designer
![Page 14: Easy programmatic access to the file system, file type associations, and new system UI controls for opening files Simple integration with the file](https://reader035.vdocument.in/reader035/viewer/2022062518/5697bf861a28abf838c87ff5/html5/thumbnails/14.jpg)
Example: capabilities XML
<Capabilities> <Capability Name="picturesLibrary" /> <Capability Name="internetClient" /></Capabilities>
![Page 15: Easy programmatic access to the file system, file type associations, and new system UI controls for opening files Simple integration with the file](https://reader035.vdocument.in/reader035/viewer/2022062518/5697bf861a28abf838c87ff5/html5/thumbnails/15.jpg)
Packages without capabilities still have access to private working
folders, and simple sensors such as accelerometers.
![Page 16: Easy programmatic access to the file system, file type associations, and new system UI controls for opening files Simple integration with the file](https://reader035.vdocument.in/reader035/viewer/2022062518/5697bf861a28abf838c87ff5/html5/thumbnails/16.jpg)
www.buildwindows.com
Accessing the file system via the file picker
demo
![Page 17: Easy programmatic access to the file system, file type associations, and new system UI controls for opening files Simple integration with the file](https://reader035.vdocument.in/reader035/viewer/2022062518/5697bf861a28abf838c87ff5/html5/thumbnails/17.jpg)
Opening multiple items
// JavaScriptvar picker = new Windows.Storage.Pickers.FileOpenPicker();
picker.fileTypeFilter.replaceAll(["*"]);
picker.pickMultipleFilesAsync().then(function (files) { if (files.size > 0) { // Manipulate array of picked file(s) } else { // No files were returned. }});
// C#FileOpenPicker picker = new Windows.Storage.Pickers.FileOpenPicker();
picker.fileTypeFilter.replaceAll(["*"]);
IReadOnlyList<StorageFile> files = await openPicker.PickMultipleFilesAsync();if (files.Count > 0) { // Manipulate array of picked file(s)} else { // No files were returned. }
![Page 18: Easy programmatic access to the file system, file type associations, and new system UI controls for opening files Simple integration with the file](https://reader035.vdocument.in/reader035/viewer/2022062518/5697bf861a28abf838c87ff5/html5/thumbnails/18.jpg)
Saving a file (JavaScript)// JavaScriptvar savePicker = new Windows.Storage.Pickers.FileSavePicker();savePicker.defaultFileExtension = ".docx";savePicker.suggestedFileName = "New Document";savePicker.fileTypeChoices.insert("Microsoft Word Document", [".docx", ".doc"]);savePicker.fileTypeChoices.insert("Plain Text", [".txt"]);
savePicker.pickSaveFileAsync().then( function (file) { if (file) { // Application now has read/write access to the saved file } else { // A file was not returned (cancelled, access denied, etc.) } });
![Page 19: Easy programmatic access to the file system, file type associations, and new system UI controls for opening files Simple integration with the file](https://reader035.vdocument.in/reader035/viewer/2022062518/5697bf861a28abf838c87ff5/html5/thumbnails/19.jpg)
www.buildwindows.com
Picker properties
• Presentation mode• thumbnail, list
• Default location• Individual user libraries or computer
• Custom button labels • Open, Save, Import, Upload, etc.
• Picker Identifier• Allows multiple picker contexts within an app
![Page 20: Easy programmatic access to the file system, file type associations, and new system UI controls for opening files Simple integration with the file](https://reader035.vdocument.in/reader035/viewer/2022062518/5697bf861a28abf838c87ff5/html5/thumbnails/20.jpg)
Programmatic access to files and folders
![Page 21: Easy programmatic access to the file system, file type associations, and new system UI controls for opening files Simple integration with the file](https://reader035.vdocument.in/reader035/viewer/2022062518/5697bf861a28abf838c87ff5/html5/thumbnails/21.jpg)
www.buildwindows.com
Programmatic access to the Pictures Library
demo
![Page 22: Easy programmatic access to the file system, file type associations, and new system UI controls for opening files Simple integration with the file](https://reader035.vdocument.in/reader035/viewer/2022062518/5697bf861a28abf838c87ff5/html5/thumbnails/22.jpg)
www.buildwindows.com
Documents Library & removable storage
• Access to the documents library and removable storage is filtered to file type associations in your package manifest.
![Page 23: Easy programmatic access to the file system, file type associations, and new system UI controls for opening files Simple integration with the file](https://reader035.vdocument.in/reader035/viewer/2022062518/5697bf861a28abf838c87ff5/html5/thumbnails/23.jpg)
www.buildwindows.com
Accessing the Documents Library
demo
![Page 24: Easy programmatic access to the file system, file type associations, and new system UI controls for opening files Simple integration with the file](https://reader035.vdocument.in/reader035/viewer/2022062518/5697bf861a28abf838c87ff5/html5/thumbnails/24.jpg)
www.buildwindows.com
File type associations
• Registration via manifest• File type associations are statically declared in the
manifest.• Users receive a toast if your app can open a previously
registered file type. • Launch events are handled as part of application
activation.// Receive activation.function onActivatedHandler(eventArgs) { if (eventArgs.kind == Windows.ApplicationModel.Activation.ActivationKind.file) { // ...
![Page 25: Easy programmatic access to the file system, file type associations, and new system UI controls for opening files Simple integration with the file](https://reader035.vdocument.in/reader035/viewer/2022062518/5697bf861a28abf838c87ff5/html5/thumbnails/25.jpg)
Device capabilities
![Page 26: Easy programmatic access to the file system, file type associations, and new system UI controls for opening files Simple integration with the file](https://reader035.vdocument.in/reader035/viewer/2022062518/5697bf861a28abf838c87ff5/html5/thumbnails/26.jpg)
www.buildwindows.com
Using devices
• Simple integration with native and specialized devices
• Declarative access model for common device classes • Webcam and microphone• Location • Proximity• SMS• And others…
• User consent model for sensitive device classes
![Page 27: Easy programmatic access to the file system, file type associations, and new system UI controls for opening files Simple integration with the file](https://reader035.vdocument.in/reader035/viewer/2022062518/5697bf861a28abf838c87ff5/html5/thumbnails/27.jpg)
www.buildwindows.com
How to handle absence of a device?
• Developers should handle the absence of a device because• The device may not always be present or operational• The user can disable access in the app
• Defer access to devices until absolutely needed
• Plan for secondary experiences when a device is not available
![Page 28: Easy programmatic access to the file system, file type associations, and new system UI controls for opening files Simple integration with the file](https://reader035.vdocument.in/reader035/viewer/2022062518/5697bf861a28abf838c87ff5/html5/thumbnails/28.jpg)
www.buildwindows.com
Consent prompt and granting/disabling access (location)
demo
![Page 29: Easy programmatic access to the file system, file type associations, and new system UI controls for opening files Simple integration with the file](https://reader035.vdocument.in/reader035/viewer/2022062518/5697bf861a28abf838c87ff5/html5/thumbnails/29.jpg)
Recap
![Page 30: Easy programmatic access to the file system, file type associations, and new system UI controls for opening files Simple integration with the file](https://reader035.vdocument.in/reader035/viewer/2022062518/5697bf861a28abf838c87ff5/html5/thumbnails/30.jpg)
www.buildwindows.com
Recap
• Declare the capabilities you need
• Request only the capabilities you need
• Defer using devices until they are actually needed
• Build great experiences that respect customer decisions
![Page 31: Easy programmatic access to the file system, file type associations, and new system UI controls for opening files Simple integration with the file](https://reader035.vdocument.in/reader035/viewer/2022062518/5697bf861a28abf838c87ff5/html5/thumbnails/31.jpg)
www.buildwindows.com
Related sessions
• [PLAT-282T] File type associations and AutoPlay• [HW-745T] Reimagining the experience for connecting with
devices• [HW-747T] Building Metro style apps that connect to
specialized devices • [PLAT-785T] Creating connected apps that just work on
today's networks • [PLAT-894T] Seamlessly interacting with web and local data
![Page 32: Easy programmatic access to the file system, file type associations, and new system UI controls for opening files Simple integration with the file](https://reader035.vdocument.in/reader035/viewer/2022062518/5697bf861a28abf838c87ff5/html5/thumbnails/32.jpg)
www.buildwindows.com
Further reading and documentation
• File SDK samples• File access• File picker• Folder enumeration
• Device SDK samples• Geolocation• Media capture
![Page 33: Easy programmatic access to the file system, file type associations, and new system UI controls for opening files Simple integration with the file](https://reader035.vdocument.in/reader035/viewer/2022062518/5697bf861a28abf838c87ff5/html5/thumbnails/33.jpg)
www.buildwindows.com
• Feedback and questions http://forums.dev.windows.com
• Session feedbackhttp://bldw.in/SessionFeedback
thank you
![Page 34: Easy programmatic access to the file system, file type associations, and new system UI controls for opening files Simple integration with the file](https://reader035.vdocument.in/reader035/viewer/2022062518/5697bf861a28abf838c87ff5/html5/thumbnails/34.jpg)
© 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.
![Page 35: Easy programmatic access to the file system, file type associations, and new system UI controls for opening files Simple integration with the file](https://reader035.vdocument.in/reader035/viewer/2022062518/5697bf861a28abf838c87ff5/html5/thumbnails/35.jpg)