Search code examples
c#windows-store-appsmicrosoft-metrowindows-8.1windows-10

How to launch camera app from my windows 10 app programmatically?


I am developing a windows 10 app. Please tell me a way to open Camera app from my windows store app. I know we can use LaunchUriAsync function to open different app which has a registered Uri in registry. But the problem is I don't know what is the registered URI for Microsoft windows default camera app. If anyone knows the camera URI please share with me. Or please tell me a way to open windows store app which has no registered URI.


Solution

  • Opening the camera app can fail for various reasons, and the camera app itself may just throw out an error message if the user's PC doesn't have a camera available (ie, no webcam, etc), so I'd strongly recommend NOT doing this. That said...

    On Windows 10, at least, the default camera app installs with a protocol URI of microsoft.windows.camera:. (You can find installed protocols under Control Panel\Programs\Default Programs\Set Associations) Edit: Note, turns out that this protocol isn't registered on windows 8.1, so keep that in mind too!

    You can use the LaunchUriAsync API to call that URI, and that should open the Camera app:

    await Launcher.LaunchUriAsync(new Uri("microsoft.windows.camera:"));
    

    As I said before though, this could fail for a bunch of reasons, so I wouldn't recommend this. I'd recommend using the Camera API and building your own camera controls if you need that functionality, since you can probably test if the user even has a camera to open, with a bit of luck. See the Camera Sample we maintain on GitHub if you want an example of that.