Pefeo Agenco
Pefeo Agenco

Reputation: 75

SurfaceView (camera preview) goes black after screen On/Off

I'm trying to understand interesting thing. I made simple application with SurfaceView and Button. SurfaceView shows camera preview and Button shoot picture. Everything goes good except one moment:

If i press home button, my app goes to background, ok, then i turn screen off/on, then i tap on app icon and my app moves to foreground and everything is correct, i see preview camera again. BUT If i turn screen off/on without moving my app to background, then i see black preview without camera and cant make any pictures.

Please, help, i broke my brain :)

Thank you for your help!

Upvotes: 0

Views: 3233

Answers (1)

android developer
android developer

Reputation: 116342

is it possible that the activity is being destroyed and yet the camera is now still "locked" so not even the camera app can show a preview of it?

anyway , you should stop previewing the camera upon onPause (and releasing it upon onDestroy) and resume it when needed.

Upvotes: 1

Related Questions