Sunday 15 April 2012

How to start front facing camera in android Using Camera Intent? -


I am developing an app in which I want to open the front camera on the button click (if the camera has front camera is) .

I have used this code which is running OS 3.2.1 on my Asus tablet. But the same code is not working on OS 4.2.1.

I think the code that works on all Android versions please help me with this problem

The following is my code -

  take the intent to picture intent = new intent (mediastore.action_IMUNCEECCT); Le pictorial Input Extra (MediaStore.xtra_utuutu, ure.framefile (f)); Logs. V ("", "camera id-" + camera ID); If (! TextUtils.isEmpty (camera)) {if (camera.equalsIgnoreCase ("Front")} {Log.v ("", "Inside if"); Le Pictureentant.Poot Extra ("android.intent.extras.CAMERA_FACING", camera.camerinfo.camera_fasei.giraf); } Else {Log.v ("", "Inside else"); Le Pictureentant.Poot Extra ("android.intent.extras.CAMERA_FACING", camera.camerinfo.camera_faccing_back); }} StartActivityForResult (Le Pictureentent, Action Code); Note: This feature is available in Gingerbread and Up version. Intent does the operation of the camera in its own way This technique is used when you are using SurfaceView to take advantage of the camera's performance.  
  Private Camera openFrontFacingCameraGingerbread () {int cameraCount = 0; Camera camera = null; Camera Camerainfo camerainfo = new camera Camerinfo (); Cameracount = camera.GetNumberoff camera (); (Camera.fax = camera; cameroinfo.camra_faccing_front) {try {cam = Camera.open (for example, camcamax = 0; cam idx; lt; camaccax ++) (camera.getcamamarinefo (cmidx, camerainfo); CamIdx);} hold (runtime exemption e) {log. (Tag, "The camera failed to open:" + e.getLocalizedMessage ());}}} returning camera;}   

In the manifest file:

  & lt; use-permission Android: name = "android.permission.CAMERA" /> & gt; & lt; utility-A Droid: name = "android.hardware.camera" Android: Required = "False" /> & lt; Usage-facility Android: name = "android.hardware.camera.front" Android: Required = "False" / & Gt;    

No comments:

Post a Comment