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 8645127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:28:10+00:00 2026-06-12T12:28:10+00:00

I’m testing my app on HTC Desire with Android 2.2. and it works exactly

  • 0

I’m testing my app on HTC Desire with Android 2.2. and it works exactly as I’d love to. I use Sherlock packages to have same style on older devices as on newer.

My AVD is set to use the latest android, and it also looks ok. Then I’ve placed it to Samsung Galaxy S2, and as I work with camera and gallery images, they are rotated wrong. It seams that something on Samsung (camera app, android it self) does not or it does check EXIF and my images are oriented wrong. Portrait images are loaded in landscape, and landscape images are loaded in portrait.

  1. I guess I need to check EXIF somehow and ignore it in order to load images as they are?
  2. Bigger problem is – how to know if there are any other devices (some HTC, some HUAWEI some whatsoever) that will do similar problem? I thought all android devices behave the same way beside having 4 screen size groups…

Tnx.

  • 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-12T12:28:11+00:00Added an answer on June 12, 2026 at 12:28 pm

    Without any code is hard to tell what’s going on.

    The most simple way i’ve found is to read the EXIF information and check if the image needs rotation. To read more on ExifInterface class on Android:
    http://developer.android.com/intl/es/reference/android/media/ExifInterface.html

    That said, here is some example code:

    /** An URI and a imageView */
    public void setBitmap(ImageView mImageView, String imageURI){
        // Get the original bitmap dimensions
        BitmapFactory.Options options = new BitmapFactory.Options();            
        Bitmap bitmap = BitmapFactory.decodeFile(imageURI, options);
        float rotation = rotationForImage(getActivity(), Uri.fromFile(new File(imageURI)));
    
        if(rotation!=0){
            //New rotation matrix
            Matrix matrix = new Matrix();
            matrix.preRotate(rotation);
            mImageView.setImageBitmap(Bitmap.createBitmap(bitmap, 0, 0, reqHeight, reqWidth, matrix, true));
        } else {
            //No need to rotate
            mImageView.setImageBitmap(BitmapFactory.decodeFile(imageURI, options));
        }
    }
    
    
    /** Returns how much we have to rotate */
    public static float rotationForImage(Context context, Uri uri) {
            try{
                if (uri.getScheme().equals("content")) {
                    //From the media gallery
                    String[] projection = { Images.ImageColumns.ORIENTATION };
                    Cursor c = context.getContentResolver().query(uri, projection, null, null, null);
                        if (c.moveToFirst()) {
                            return c.getInt(0);
                        }               
                } else if (uri.getScheme().equals("file")) {
                     //From a file saved by the camera
                        ExifInterface exif = new ExifInterface(uri.getPath());
                        int rotation = (int) exifOrientationToDegrees(exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL));
                        return rotation;
                }
                return 0;
    
            } catch (IOException e) {
                Log.e(TAG, "Error checking exif", e);
                return 0;
            }
    }
    
    /** Get rotation in degrees */
    private static float exifOrientationToDegrees(int exifOrientation) {
            if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_90) {
                return 90;
            } else if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_180) {
                return 180;
            } else if (exifOrientation == ExifInterface.ORIENTATION_ROTATE_270) {
                return 270;
            }
            return 0;
    }
    

    If there is an error you will see the log “Error checking EXIF” on rotationForImage function.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,
I have a small JavaScript validation script that validates inputs based on Regex. I
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported

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.