Activate the video camera in the background

I want to activate the camcorder when my app is in the background.
So to do this, I created a service that starts / stops the video camera ...

The problem is I need to create SurfaceView

in the main activity (the one that called this service in my case) so that setPreviewDisplay

. But when my application is in the background, I get Application lost the surface

ERROR.

I know what I need SurfaceView

to activate the camcorder, but is there a better solution for activating the camcorder when my app is in the background?

0


source to share


1 answer


I'm not sure if I fully understand this question, but I think the problem is that the service is not really designed to handle UI related classes as it does.

Try to package all your camera code, including the SurfaceView setup, into an Activity. Then ask your Service to activate the action by starting a Job for this. Basically, the whole Service makes a selection when a camera is needed and then starts an Activity.



I am assuming that you are fine with the camera preview appearing on the screen.

0


source







All Articles