Follow us on X (Twitter)  Like us on Facebook  Connect with us on LinkedIn  Subscribe to our YouTube Channel  Subscribe to our WhatsApp Group

How to check the supported Camera Type in Windows Phone?


If you are a WPDev and building Windows Phone app and/or game that uses primary or secondary (front facing camera), you might need to check whether the device supports either or both of them. Windows Phone SDK provides APIs to check for supported camera type. - Article authored by Kunal Chowdhury on .

If you are a WPDev and building Windows Phone app and/or game that uses primary or secondary (front facing camera), you might need to check whether the device supports either or both of them. Windows Phone SDK provides APIs to check for supported camera type.

 

In this blog post, we will discuss about this API and learn how to know whether the phone supports either or both of those camera types.

 

The abstract class “Camera” present under the namespace “Microsoft.Devices” provides you the required API to check whether the Windows Phone device supports Primary Camera or Front Facing Camera. The Camera class contains a static method named “IsCameraTypeSupported(CameraType type)” that returns a boolean value indicating whether the passed CameraType is available in the device. The parameter of CameraType could be either “Primary” or “FrontFacing”.

 

Here is the code to know the supported camera type in a Windows Phone device:

 

// this will return boolean value indicating whether the device has Primary Camera
var hasPrimaryCamera = Camera.IsCameraTypeSupported(CameraType.Primary);

 

// this will return boolean value indicating whether the device has Front Facing Camera var hasFrontFacingCamera = Camera.IsCameraTypeSupported(CameraType.FrontFacing);

 

While using the camera APIs in Windows Phone, you might get an “UnauthorizedAccessException” as shown below, if you did not configure your project to apply proper capability settings:

 

UnauthorizedAccessException when accessing Camera APIs in Windows Phone

 

To do this, open the WMAppManifest.xml file and navigate to the Capabilities tab as shown in the below screenshot. There you will find a checkbox named “ID_CAP_ISV_CAMERA” listed under the Capabilities. Mark this capability as checked and you will be good to go.

 

Enable the ID_CAP_ISV_CAMERA Capability in Windows Phone application

 

Did this post help you? Don’t forget to share it with your friends and network. Subscribe to my blog’s RSS Feed to get instant update on new blog post. Are you available on Twitter or Facebook? I am available there too. Do connect with me to get regular updates on various technical/non-technical posts.

 

Have a question? Or, a comment? Let's Discuss it below...

Thank you for visiting our website!

We value your engagement and would love to hear your thoughts. Don't forget to leave a comment below to share your feedback, opinions, or questions.

We believe in fostering an interactive and inclusive community, and your comments play a crucial role in creating that environment.