I'm developing a Service, running in background, that uploads succesfully images and data to the web.
Now I want to upload an image taken by the Camera.
Is it possible to use the camera in a background service without preview on Android 2.2?
I found various contrastants answers on web...
How can I do it?
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 .
For Android users -- Open the camera app, press and keep holding the shutter button. -- This automatically activates the Burst Mode and clicks multiple photos until you release the button.
Focus and click on the Capture button on the camera app. Once you click on the Capture button, the timer will do a countdown, which you will be able to see on your device's screen. Once the countdown is up, your camera will take a picture, which will then be automatically saved in your device's gallery.
You can take pictures without preview with an dummy view.
like:
SurfaceView view = new SurfaceView(this);
c.setPreviewDisplay(view.getHolder());
c.startPreview();
c.takePicture(shutterCallback, rawPictureCallback, jpegPictureCallback);
It's not possible without the preview / surface view.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With