Run The Camera In the background !

Ahmed Wassim BEN SALEM (ENISo) 241 Reputation points
2021-04-09T15:04:55.767+00:00

Hello everyone ,
so i managed to open a strem live from camera . and getting images from it every 2 sec .
what i want to do is runing the camera in the background and get data from it . i dont want the camera to be displayed in my screen .
Any suggestion !

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,297 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,308 questions
0 comments No comments
{count} votes

Accepted answer
  1. Cole Xia (Shanghai Wicresoft Co,.Ltd.) 6,751 Reputation points
    2021-04-12T06:48:04.503+00:00

    Hello,

    Welcome to Microsoft Q&A!

    On Android 9 (API level 28) and later, apps running in the background cannot access the camera. Therefore, you should use the camera either when your app is in the foreground or as part of a foreground service.

    For foreground service please check here .

    If your app targets Android 11 (API level 30) or higher and accesses the camera in a foreground service, declare the camera foreground service types, as attributes of your <service> component.

       <manifest>  
           ...  
           <service ... android:foregroundServiceType="camera" />  
       </manifest>  
    

    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful