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
  • 37,241
  • 25
  • 195
  • 267
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
  • 6,140
  • 3
  • 36
  • 67
0

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

jigar
  • 1,571
  • 6
  • 23
  • 46