Manjeet
Manjeet

Reputation: 317

Screen goes black for a while if camera orientation is changed

While changing device orientation from portrait to landscape and landscape to portrait it is happening.The problem I am facing is while changing from one mode to another screen goes black for a while.It seems activity is recreated.

I used android:configChanges but after that programatically surface view orientation I am not able to change.

How to avoid the black screen while changing camera mode?

Upvotes: 2

Views: 1179

Answers (1)

Vipul
Vipul

Reputation: 28103

When activity recreated it does all things you requested in onCreate().

If you are using Activity then you should consider using onRetainNonConfigurationInstance() for the heavy objects in your activity.

But remember onRetainNonConfigurationInstance() is now deprecated.

If you are comfortable with Fragments then you should use setRetainInstance(boolean) instead.

Below links will help you.

http://developer.android.com/resources/articles/faster-screen-orientation-change.html http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/Fragment http://android.codeandmagic.org/2011/07/android-fragments-saving-state-and-screen-rotation/

Upvotes: 2

Related Questions