O'Reilly logo

Xamarin Mobile Development for Android Cookbook by Matthew Leibowitz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required