Using the camera

Making use of the camera allows the user to interact with the real world through the device. This can range from taking a photo and adding a message and effects all the way to providing an augmented reality experience.

How to do it...

If our app requires a photo, we can make use of the camera to record an image. However, we need to first ensure that there is a camera available on the device for us to use:

  1. If our app requires the camera and cannot function without it, we can enforce this by specifying that there must be a camera on the device in the features:
    [assembly: UsesFeature(PackageManager.FeatureCamera)]
    [assembly: UsesFeature(PackageManager.FeatureCameraFront)]
  2. If the feature is not required, we can indicate that it is optional ...

Get Xamarin Mobile Development for Android Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.