Search code examples
androidkotlinandroid-camera

Android recording video in Backround


I am developing a Kotlin android app, when something happens in the app, I want the front-facing camera to record in the background to capture a users reaction for 5 seconds then storing the video in an object to be used in another feature, leaving the apps activity will break it so i am wondering is it possible to do this in the background?

Thanks in advance


Solution

  • You can use foreground services to use the camera in the background. Foreground services keep running even after the Application is removed by the user from recents screen.

    Make sure to read the restrictions applied by Android to these kinds of services: https://developer.android.com/guide/components/foreground-services#access-restrictions