2

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);
    }});
shyam
  • 1,276
  • 4
  • 25
  • 51

2 Answers2

1

solve using this....

setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

shyam
  • 1,276
  • 4
  • 25
  • 51
0

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.

Community
  • 1
  • 1
Andras Balázs Lajtha
  • 2,576
  • 25
  • 32
  • hey i had tried this then also i am loosing data ..can u pls tell me how to i restrict the gallery orientation from my code in my application only? – shyam Oct 20 '11 at 07:35
  • i think that i pick image from landscape mode and i set the return activity in portrait mode only then there should be any problem means data is not coming from landscape to portrait mode...what u think?thanks – shyam Oct 20 '11 at 07:38
  • Could you post the code from the point you reveive the onActivityResult until sending the email? What kind of infirmation do you need for the email sending and what information you are missing when you send the mail? – Andras Balázs Lajtha Oct 20 '11 at 17:35