4

I am writing a cross platform Xamarin.Forms Application where my app uses camera and requests camera permissions from the user at runtime. I am using Xamarin.Essentials nuget package to check and request permissions. But before I request camera access permission, I want to make sure the device has camera hardware. Is there any cross platform way to check whether the device has camera hardware? I checked the Xamarin.Essentials documentation and I don't seem to find it anywhere.

zafar
  • 1,965
  • 1
  • 15
  • 14

2 Answers2

1

We should use Media Picker now, as support for Media plugin officially stopped in Dec 2020:

Xamarin.Essentials 1.6 introduced official support for picking/taking photos and videos with the new Media Picker API. [...] I will officially be archiving this library in December 2020 [...]

Mariola
  • 21
  • 2
  • Does its `IsCaptureSupported` work the same as `IsCameraAvailable` or does it, for example, consider permissions, too? EDIT: Okay, checked it in GitHub: yes, it does (at least for Android, what is the only thing it's interesting for me). – Christoph Mett Sep 09 '22 at 13:47
0

the Media plugin has this API

CrossMedia.Current.IsCameraAvailable
zafar
  • 1,965
  • 1
  • 15
  • 14
Jason
  • 86,222
  • 15
  • 131
  • 146
  • 1
    I was expecting MediaPlugin as part of Xamarin.Essentials package. If not, at least Xamarin.Essentials should provide a way to check that without relying on MediaPlugin. Thank you anyways, I should be able to add that package and make it work. – zafar May 22 '20 at 15:27
  • I just realized while installing the Media Plugin nuget package, that it is dependent on Xamarin.Essentials. So I guess it is intentionally separated out – zafar May 22 '20 at 15:32