shyam
shyam

Reputation: 1306

restrict the pick from gallery image in always portrait mode

i am able to open gallery for choose image and selected image set as attachment now when i open gallery if my device in portrait mode then my image is attaching and at the time of picking image if my device in landscape mode then image attachment failed...so i want to open gallery always in portrait mode even i round the device to landscape mode ...so how to achive this restriction...

my code for open gallery is

  Button gallerybtn = (Button) findViewById(R.id.button1);
    gallerybtn.setOnClickListener(new View.OnClickListener()
    {
        public void onClick(View v) {

            Intent intent = new Intent();
            intent.setType("image/*");
            intent.setAction(Intent.ACTION_GET_CONTENT);
            startActivityForResult(Intent.createChooser(intent,
                    "Select Picture"), SELECT_PICTURE);
    }});

Upvotes: 2

Views: 856

Answers (2)

shyam
shyam

Reputation: 1306

solve using this....

setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

Upvotes: 1

I'm thinking that your problem is not wether or not the gallery is in landscape mode, but that when Activity returns, and your phone is in landscape mode, onCreate is called again, and you loose some data. In stead of fixing the gallery orientation, try fixing the orientation of your own Activity:

<activity android:name="MyActivity"
   android:label="@string/app_name"
   android:screenOrientation="portrait">

You can find a way here to make persistent initialization, if you don't want to fix orientation of Activity.

Upvotes: 0

Related Questions