Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8788897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:15:14+00:00 2026-06-13T22:15:14+00:00

How to maintain camera display orientation in android when i create custom camera class.

  • 0

How to maintain camera display orientation in android when i create custom camera class.
when i not perfect solution for more then android device then what i do for this scenarios and when some device do on camera landscape or some device do on camera portrait.

 public CameraSurface(Context context) {
        super(context);

        try {
            holder = this.getHolder();
            holder.addCallback(this);
            holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    @Override
    public void surfaceCreated(SurfaceHolder holder) {
        try {
            // Open the Camera in preview mode
            this.camera = Camera.open();
            this.camera.setPreviewDisplay(holder);
        } catch (IOException ioe) {
            ioe.printStackTrace(System.out);
        }
    }

    @Override
    public void surfaceDestroyed(SurfaceHolder holder) {
        // Surface will be destroyed when replaced with a new screen
        // Always make sure to release the Camera instance
        camera.stopPreview();
        camera.release();
        camera = null;
    }

    @Override
    public void surfaceChanged(SurfaceHolder holder, int format, int width,
            int height) {
        // Now that the size is known, set up the camera parameters and begin
        // the preview.
//      Camera.Parameters parameters = camera.getParameters();
//      System.out.println("height...."+width+" height....."+height);
//      parameters.setPreviewSize(width, height);
//      camera.setParameters(parameters);
//      camera.startPreview();
        Camera.Parameters parameters = camera.getParameters();
        List<Camera.Size> previewSizes = parameters.getSupportedPreviewSizes();

        // You need to choose the most appropriate previewSize for your app
        Camera.Size previewSize;
        if(previewSizes.size() > 1){
            previewSize =previewSizes.get(1);  // .... select one of previewSizes here
        }else{
            previewSize =previewSizes.get(0);
        }
        parameters.setPreviewSize(previewSize.width, previewSize.height);
        camera.setParameters(parameters);
        camera.setDisplayOrientation(90);
        camera.startPreview();
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T22:15:16+00:00Added an answer on June 13, 2026 at 10:15 pm

    Following two links will help you:

    Using Camera API.
    Android Camera Preview is sideways.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I maintain an Android app and am not using Eclipse. I am not using
I maintain a Python program that provides advice on certain topics. It does this
I maintain a project that has a function definition similar to this: def f(a,
I maintain a dispatch queue as a property with my view controller. I create
I maintain a legacy ASP.NET custom control component that implements a menu using CSS
/*Forum maintain scrollposition*/ $('#wpf-wrapper a').each(function() { $(this).click(function() { $(this).attr('href', $(this).attr('href') + #wpf-wrapper); }); });
I maintain an Eclipse plug-in that was written for Eclipse 3.2. This plug-in writes
I maintain the build system at my company, which is currently using CVS. This
I maintain a test suite utilizing Selenium and Capybara. While I can convince Selenium
I maintain a documentation with git and GitHub. The source files are TEX files

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.