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

  • SEARCH
  • Home
  • 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 8640865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:22:57+00:00 2026-06-12T11:22:57+00:00

In my camera app, the UI orientation is fixed to portrait. the preview displayed

  • 0

In my camera app, the UI orientation is fixed to portrait.

the preview displayed correctly on both landscape and portrait by setting camera.setdisplayorientation(90).

I can take picture and save it to file.
when I display it by ImageView,
the picture that was taken in landscape orientation could display correctly.
(the top of phone in my left side)

But… the one that was taken in portrait orientation is not so lucky…
It looks like turn 90 degrees to left.

I try to detect the device orientation through sensor so that I can set the EXIF header,
but… so far…that too hard to achieve for me…does any one can help me to solve this problem?

  • 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-12T11:22:58+00:00Added an answer on June 12, 2026 at 11:22 am

    Use the getRotation method:

    Display display = ((WindowManager)
    context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    int rotation = display.getRotation();
    

    From the documentation:

    Returns the rotation of the screen from its "natural" orientation. 
    The returned value may be Surface.ROTATION_0 (no rotation), Surface.ROTATION_90, Surface.
    ROTATION_180, or Surface.ROTATION_270. 
    For example, if a device has a naturally tall screen, and the user has turned it on its side to go into a landscape orientation, the value returned here may be either Surface.ROTATION_90 or Surface.ROTATION_270 depending on the direction it was turned. 
    The angle is the rotation of the drawn graphics on the screen, which is the opposite direction of the physical rotation of the device.
    For example, if the device is rotated 90 degrees counter-clockwise, to compensate rendering will be rotated by 90 degrees clockwise and thus the returned value here will be Surface.ROTATION_90.
    

    getRotation was introduced from Android 2.2. Use getOrientation if your target are older devices.

    Got answer form here:
    how to detect orientation of android device?

    If you just want to detect orientation of the device then you can use an OrientationEventListener.

    here’s the official docs:
    http://developer.android.com/reference/android/view/OrientationEventListener.html#onOrientationChanged(int)

    But before you use anything, check out this excellent blog post about orientation handling in android:
    http://android-developers.blogspot.in/2010/09/one-screen-turn-deserves-another.html

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

Sidebar

Related Questions

I have a App which uses the camera to take a picture. The camera
My app is screen_orientation_portrait,but when I opened camera,the picture in my camera is 90degreed
What does it take to add a menu option to the iPhone's Photos/Camera app
I'm having an issue where I'm using the camera app to take a photo
My goal is to write a custom camera view controller that: Can take photos
In my camera app, you can switch between the front and back camera. When
I am developing an app which takes a preview of the device's camera and
My phone crashes after i pause my camera app, then switching back and take
If I take a photo with a camera it stores the orientation/angle of the
I'm working on an Android app that shows a camera preview. Ideally I'd like

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.