0

When my screen rotate the images in the ImageView are Gone ( the imageView is restart to the original view)

i want to keep the images in the imagesView after the screen rotate.

i have severals Bitmaps that i downloaded to my app and then i put them as background of the imagesView..

i understand how can i restore the Texviews and EditText texts, however not for images:

Losing data when rotate screen

thanks

Community
  • 1
  • 1
Adir Rahamim
  • 453
  • 1
  • 12
  • 31
  • Are you downloading images & displaying them in ImageView? – Vishal Pawale May 12 '13 at 19:34
  • yes, i download them as byte array, then decode them to bitmap and then display them in imageView – Adir Rahamim May 12 '13 at 19:37
  • I'm going bit off the topic but consider using https://github.com/koush/UrlImageViewHelper, it will do image caching & loading by itself.And if you consider this option then you can just add the image url in `Bundle` under `onSaveInstanceState` and retrieve same url in `onResume` – Vishal Pawale May 12 '13 at 19:40

1 Answers1

-2

add this configChanges ="oriention" to your activity in manifest

Noundla Sandeep
  • 3,334
  • 5
  • 29
  • 56
  • do i need to add it to every Activity? is it will restore everything after screen rotation? thanks alot – Adir Rahamim May 12 '13 at 19:30
  • Where you require you have to add. Means in which activity that image is present. – Noundla Sandeep May 12 '13 at 19:31
  • Also, if i add it, do i need to override the methods:onSaveInstanceState and onRestoreInstanceState? Also, does it saves the TextView and EditText state? – Adir Rahamim May 12 '13 at 19:32
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/29806/discussion-between-noundla-and-adir-rahamim) – Noundla Sandeep May 12 '13 at 19:37
  • 4
    This is a hack, and a bad one. Even Google says it should be used "as a last resort". By adding this, the bug is *avoided* rather than fixed but is still there if the user changes their timezone, or locale, or slides out a keyboard, or attaches a USB HID device or any of the other reasons the activity will be destroyed and recreated. The correct solution is to learn and correctly code for the Activity life cycle which is what the OP has not done and why there is a bug. The Play store is littered with buggy apps because the developer used this hack. It should not be promoted on SO. – Simon May 12 '13 at 20:09
  • @Simon I agree with you. I know that too. But for a simple reason we shouldn't go with the complexity,right? If we have more functional changes on orientation change then go and use the activity life cycle methods as per requirement. – Noundla Sandeep May 13 '13 at 04:50