0

I snap a photo, and it gets placed onto an ImageView. When the user sees the page where the Image View is, and I turn the phone sideways where the orientation is horizontal, the app immediately returns to the app's main screen. Any ideas?

Sapp
  • 1,773
  • 6
  • 29
  • 51
  • See http://stackoverflow.com/questions/456211/activity-restart-on-rotation-android there are some detailed answers here. – Alex Jasmin Nov 18 '10 at 00:49

1 Answers1

2

Rotating the phone recreates the activity. Implementing the onSaveInstanceState() and onCreate() methods to properly save and restore the state of the activity should fix the problem.

Alex Jasmin
  • 37,102
  • 6
  • 72
  • 63
  • Pardon my ignorance on that - but do you mean for each class? I have super.onCreate(savedInstanceState); in the class that it is changing orientation in, and it still goes back to the app's home screen. – Sapp Nov 18 '10 at 00:40
  • What do you mean by homes screen? Does it switch to another activity? Does a popup disappear? Does the view get reset? – Alex Jasmin Nov 18 '10 at 00:58
  • it goes from one of my classes called by setContentView back to my app's main class – Sapp Nov 18 '10 at 01:16
  • Your activity is destroyed by default when you rotate the screen. If you always call `setContentView()` with the same view inside `onCreate()` it will always switch back to it. – Alex Jasmin Nov 18 '10 at 02:06
  • If you are completely replacing the view perhaps it would be simpler to switch to another activity instead. – Alex Jasmin Nov 18 '10 at 02:18