views:

24

answers:

2

Whenever the Android device locks and I unlock it, the image that was displayed in the ImageView disappears. What do I need to do to redisplay it or prevent this from happening.

More: I have a view that displays video, images or text depending on the context and three subclasses that extend the parent view. On creation, I replace the display view with the View object returned from createMediaPreview(), which each subclass implements.

Thanks in advance

+2  A: 

You'll probably want to call createMediaPreview() again in the onResume() method:

http://developer.android.com/reference/android/app/Activity.html#onResume()

roundhill
A: 

As roundhill mentioned, you need to setup your image in onResume(). OnCreate() only gets called when the Activity is first instantiated. When the phone goes to sleep, the Activity remains in memory, in sleep mode. When you unlock the phone, Android OS will bring it back to the foreground (it doesn't call onCreate() since it already finds this activity in memory, it already exists). Check the Activity's lifecycle here

Ricardo Villamil