How to use CameraX in foreground service? Android Studio

Viewed 104

I need to use the Camera frames even the app is in background. After I have searched how to do it I encountered to foreground service. However, when the app is in background, the streaming from the PreviewView stops, so I cannot use the advantage of using foreground service.

Camera State
Camera@50536c5[id=1] CLOSED
Camera@c3b62c2[id=0] UNKNOWN
Camera@a1a5527[id=2] UNKNOWN

Whenever I touch the home button, the warning above comes to Log-cat and stop delivering frames to ImageAnalysis. I cannot process the frames.

Is there a way to keep the streaming of frames awake, even the app is on background?

ps : manifest has been edited as android:foregroundServiceType="camera"

0 Answers
Related