NFC based Windows 8/Windows Phone 8 photo sharing with PixPresenter
- Posted: Dec 26, 2012 at 6:00AM
So we have all those pictures we took yesterday and it's a good time to share them with friends and co-workers. But we don't really want to upload them, post them to social sites, etc, We want a more personal, face-to-face sharing experience. We have the pictures on our devices, we should be able to easily share them between them.
And here's some code that does just that (which you can use to learn how you can do it in your apps too!)
This sample demonstrates code sharing techniques you can use when developing an app for Windows 8 and Windows Phone 8.
PixPresenter is a photo sharing app that enables you to connect to another device using Proximity (NFC) and a tap gesture, and then send pictures back and forth between the connected devices. It demonstrates code sharing techniques that you can use when developing an app for both Windows 8 and Windows Phone 8. These sharing techniques include sharing .NET code in a Portable Class Library, writing code using Windows Runtime APIs common to both platforms and linking the code to both projects using Add as Link, and sharing C++ code in a Windows Runtime Component. For details about these sharing techniques, see Windows Phone 8 and Windows 8 app development. You can also view a session from the Build 2012 conference that describes PixPresenter and the code sharing techniques used to create it. To view the session, see How to Leverage your Code across WP8 and Windows 8.
This sample contains the following projects.
PixPresenter.Portable A Portable Class Library that contains portable .NET code. This compiles to a single binary which is used by both the Windows Phone PixPresenter app and the Windows Store PixPresenter app. The code in this project defines the view models used by PixPresenter and localizable string resources.
PixPresenter.Win8 The Windows Store PixPresenter app. It contains the UI (views) for the app as well as platform-specific code that is neither shareable nor portable.
PixPresenter.WP8 The Windows Phone PixPresenter app. It contains the UI (views) for the app as well as platform-specific code that is neither shareable nor portable.
FastFilters.Win8 A Windows Runtime Component project for the Windows Store app. It contains native code to convert a picture to grayscale. Windows Runtime Components are not binary compatible across Windows 8 and Windows Phone 8. Therefore a separate project is needed to compile the Windows Runtime Component to each platform.
FastFilters.WP8 A Windows Runtime Component project for the Windows Phone app. It contains native code to convert a picture to grayscale. Windows Runtime Components are not binary compatible across Windows 8 and Windows Phone 8. Therefore a separate project is needed to compile the Windows Runtime Component to each platform.
Shared folder A folder containing shared code that is added to each app using the Add as Link capability in Visual Studio.
One solution was used for convenience, to maintain all code in one place. When the solution is built, it generates the Portable Class Library, the image filtering library, the Windows Store app and the Windows Phone app.
Portable Class Library projects can’t be created or compiled using the Express versions of Visual Studio. Use Visual Studio 2012 Pro, Enterprise or Ultimate to build this sample. You can add a reference to a Portable Class Library in all versions of Visual Studio, including Express.
PixPresenter can connect phone to phone, phone to computer, and computer to computer.
PixPresenter displays photos stored in albums from the photos library on the phone and in folders from the Pictures library on a Windows 8 computer. If you do not have pictures in these locations, the PixPresenter UI will be empty.
Before you run PixPresenter using the Windows Phone 8 emulator, open the emulator and access the pictures library. This will populate the media pictures library that PixPresenter uses to access the photos on a phone.
PixPresenter does not support Proximity connections using Wi-Fi Direct.
To test on Windows 8, you can use the Proximity emulator to run the app between Windows 8 computers on a local network. This capability is not available for the Windows Phone 8 emulator. For information on downloading and installing the Proximity network emulator on Windows 8, see Testing and Troubleshooting Proximity in apps
Verify that Bluetooth is enabled on devices when running the PixPresenter sample app.
The solution defines multiple build configurations, accessible from the Build | Configuration Manager… menu item in Visual Studio. To run the app on the Windows Phone 8 emulator and the Windows 8 simulator, or Local Machine, select the Mixed Platforms configuration. To deploy to an ARM device, such as a Windows Phone 8 device, select the ARM configuration, build and deploy.
A couple shots of the Windows Store app running (yes, we have dogs and cats living together...
With today's project and Monday's you've got two examples of building Photo app's for Windows 8 (and one for Windows Phone 8). The rest is up to you to build the next great photo experience.