0

I'm building an app which will open an image from gallery. The image is opened successfully but I would like to know if I can force the image to be opened in portrait mode?

This is the Intent I'm using:

        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(Uri.fromFile(file),"image/*");
        intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
        startActivity(intent);
Cœur
  • 34,719
  • 24
  • 185
  • 251
user2507920
  • 63
  • 2
  • 10

2 Answers2

0

if you having an issue with the image rotation well i advice you to use this method as its the simplest and most efficient way.

            String[] orientationColumn = { MediaStore.Images.Media.ORIENTATION };
        @SuppressWarnings("deprecation")
        Cursor cur = managedQuery(imageFileUri, orientationColumn, null,
                null, null);
        int orientation = -1;
        if (cur != null && cur.moveToFirst()) {
            orientation = cur.getInt(cur
                    .getColumnIndex(orientationColumn[0]));
        }
        Matrix matrix = new Matrix();
        matrix.postRotate(orientation);
        bmp = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(),
                bmp.getHeight(), matrix, true);
        view.setImageBitmap(bmp);

hope this is what you are looking for :)

Kosh
  • 5,883
  • 2
  • 34
  • 67
0

use android:screenOrientation="portrait" in manifest in each <activity/> tag...it will work...my friend..try it

jigar
  • 1,491
  • 6
  • 23
  • 46