Android Question CameraEx

Giuliano Cucchiarini

Member
Licensed User
Longtime User
I am using CameraEx and I need to check if the device has both Front and Rear Cameras.
Some simple devices, for example have only one camera.
Is there any function to see if the camera is present on the device before makink the initialization?

Thank you

Giuliano
 

mangojack

Expert
Licensed User
Longtime User
try this

B4X:
Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("1")
   
   Log ("this device has  " & getNumberCameras &  "  cameras")
   
End Sub

Private Sub getNumberCameras
   
   Dim r As Reflector
   Dim ci As CameraInfoAndId
   Dim cameraInfo As Object
   Dim numCams As Int
   
   cameraInfo = r.CreateObject("android.hardware.Camera$CameraInfo")
   numCams= r.RunStaticMethod("android.hardware.Camera", "getNumberOfCameras", Null, Null)
   Return numCams
   
End Sub
 
Upvote 0
Top