2

In my app i am trying to take a pic from camera and displaying it in the imageview.Everything works fine but when i took pic from samsung galaxy s3 , it changed the orientation and displays the camera activity and onActivity result it displayed the pic in the imageView but in a fraction of seconds it changed the orientation again removed the pic from imageview.Its very weird how can i resolve this issue?

Ricky Khatri
  • 952
  • 2
  • 16
  • 42
anshul
  • 982
  • 1
  • 11
  • 33
  • possible duplicate of [Camera intent not working with Samsung Galaxy S3](http://stackoverflow.com/questions/15248265/camera-intent-not-working-with-samsung-galaxy-s3) – Alex Cohn Mar 11 '15 at 14:56

2 Answers2

2

This is probably late to answer but I think that your onCreate method is called after the orientation change thus the ImageView bitmap that you are setting is null after orientation change.

Try saving your data and variables by Overriding onSaveInstanceState(). This method is called each time the orientation changes. Save variables and values that you want to retain after orientation change.

Hope I am right and this helps!

Parvaz Bhaskar
  • 1,367
  • 9
  • 29
-1

Try this:

LinearLayout myLayout = new LinearLayout(this);
myLayout.setOrientation(LinearLayout.VERTICAL);
Ricky Khatri
  • 952
  • 2
  • 16
  • 42
  • But i need to support horizontal also. – anshul Dec 27 '12 at 06:49
  • SO you need to find out the camera pic captured state and then you can change to Horizontal also. – Ricky Khatri Dec 27 '12 at 07:07
  • I'm not totally sure this addresses the OP's question. If you believe it does, re-read his question carefully to double-check, and then edit your answer to add some explanation as to why this is correct. It is more important to communicate the underlying logic than just the code by itself - if one grasps the logic, they'll be able to write this and similar code themselves. – CodeMouse92 Sep 24 '15 at 19:47