Android Camera - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android Camera class.

This code example shows how to use the following methods: setPreviewDisplay, startPreview
        mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    } 
 
    public void surfaceCreated(SurfaceHolder holder) {
        try { 
            mCamera.setPreviewDisplay(holder);
            mCamera.startPreview();
        } catch (IOException e) {
            Log.d(TAG, "Error setting camera preview: " + e.getMessage());
        } 
    } 
 
    public void surfaceDestroyed(SurfaceHolder holder) {
    } 
     
 
    public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
 
        if (mHolder.getSurface() == null){
          return; 
Full Snippet Info
10
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getParameters, setParameters
	 *  
	 * @param state			The requested state 
	 *  
	 */ 
	protected void toggleTorch(boolean state) {
		mParameters = mCamera.getParameters();
 
		// Make sure that torch mode is supported 
		// 
		if ( this.isCapable() ) {
			if (state) {
				mParameters.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
			} else { 
				mParameters.setFlashMode(Camera.Parameters.FLASH_MODE_ON);
			} 
 
			// Commit the camera parameters 
			// 
			mCamera.setParameters(mParameters);
 

10
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getParameters, stopPreview
    { 
        Log.e(TAG, "surfaceChanged");
 
        // XXX stopPreview() will crash if preview is not running 
        if (mPreviewRunning) {
            mCamera.stopPreview();
        } 
 
        Camera.Parameters p = mCamera.getParameters();
        p.setPreviewSize(w, h);
        mCamera.setParameters(p);
        try { 
			mCamera.setPreviewDisplay(holder);
		} catch (IOException e) {
			// TODO Auto-generated catch block 
			e.printStackTrace();
		} 
        mCamera.startPreview();
        mPreviewRunning = true;
    } 
Full Snippet Info
10
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: stopPreview
    if (autoFocusManager != null) {
      autoFocusManager.stop();
      autoFocusManager = null;
    } 
    if (camera != null && previewing) {
      camera.stopPreview();
      previewCallback.setHandler(null, 0);
      previewing = false;
    } 
  } 
 
  /** 
   * Convenience method for {@link com.google.zxing.client.android.CaptureActivity} 
   */ 
  public synchronized void setTorch(boolean newSetting) {
    if (camera != null) {
      if (autoFocusManager != null) {
        autoFocusManager.stop();
      } 
      configManager.setTorch(camera, newSetting);
Full Snippet Info
10
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getParameters
		} 
		return new Size(neww, newh);
	} 
	 
	public boolean isAutoFocusSupported(android.hardware.Camera camera) {
		String focus_mode = camera.getParameters().getFocusMode();
		boolean auto_focus_supported = false;
		if ( focus_mode != null ) {
			auto_focus_supported = (focus_mode.equals(android.hardware.Camera.Parameters.FOCUS_MODE_AUTO)) || (focus_mode.equals(android.hardware.Camera.Parameters.FOCUS_MODE_MACRO));
		} 
		return auto_focus_supported;
	} 
	 
	public boolean isFlashModeSupported(android.hardware.Camera camera, String flash_mode) {
		String camera_flash_mode = camera.getParameters().getFlashMode();
		boolean flash_supported = false;
		if ( camera_flash_mode != null ) {
			List<String> modes_list = camera.getParameters().getSupportedFlashModes();
			if (modes_list != null) {
				if (modes_list.contains(flash_mode)) {
Full Snippet Info
10
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android Camera Questions & Answers:

Other Android Camera Examples

12:	public class MakePhotoActivity extends Activity {
13:	  private final static String DEBUG_TAG = "MakePhotoActivity";
14:	  private Camera camera;
15:	  private int cameraId = 0;
16:

Read More

17:		ImageButton btnSwitch;
18:	
19:		private Camera camera;
20:		private boolean isFlashOn;
21:		private boolean hasFlash;

Read More

17:		ImageButton btnSwitch;
18:	
19:		private Camera camera;
20:		private boolean isFlashOn;
21:		private boolean hasFlash;

Read More

See Code Examples for Android Camera Methods: