How to use background camera and foreground camera simultaneously? - android

My new application requirement is client wants to create a spy camera which record the video in background. Now whenever the phone is lock and user is not present so in the absens of user someone try to use the phone it will start video recording in background recording. I have done all this thing and it works like a charm no issue with this.
Now the problem is when the service start video recording in background and at that time I open my default camera app and it won't allow me to use the camera application that is but obvious because my service using that camera in background.
So my question is that can we use both background camera and foreground camera simultaneously? AFAIK it is not possible to use background camera and foreground camera.
As I searched on stack overflow someone said that Samsung s4 default application do that you can capture front and back and its I have s4 and its default application do that thing but when I installed and use my app it raise the same issue.
Right now I am planning to stop video recording when my default camera application open. But is their any other way apart from stop recording?

Related

Using Camera2 I want to turn on flashlight when Android Recording

My app shows a preview and video recording starts with a button press.
What I'm trying to achieve is when I press the button, it'll turn on flashlight after 2 second and it's still recording.
However I couldn't find a way to do so. On Camera2 API I can use FLASH_MODE_AUTO to turn on the flashlight before recording video, but that doesn't work when video recording.
I also tried to build another button for control flashlight, but if I don't build preview before flashlight, it won't work, and if I build it, it will stock the app, I'm guessing cause I call the preview twice.
If anyone have same question with mine, we can discuss.
To manually control the flashlight with camera2, you need to set CONTROL_AE_MODE to ON to disable automatic flash control, and set FLASH_MODE to OFF to start with the flash off, in your initial repeating request.
Once you want to turn the flashlight on while you're recording, set FLASH_MODE to TORCH.

Android Screen recording event into my Android application

I want screen recording event into my Android application, for example some third party application start to capture or record screen at that time my Android application detect that event and show one warning dialog to user that detect screen recording.
if any one know about this please help me about this. I am searching about this but all tell about "FLAG_SECURE". I want Event of screen recording not restrict screen recording.

Android record camera and music from players

I am trying to do following functionality in my mobile app:
1) In my app I have record button. When pressed it starts camera recording
2) if I have music playing in my mobile phone in any of
players - this music should overlay the video
3) External microphone
in this situation should also record additional sound
So as a result we will have video record+music+microphone sound
Right now, I got stuck while trying to get access to android.permission.CAPTURE_AUDIO_OUTPUT
(I am not using root access btw and can't use it)
Is there a way to solve 1+2+3(record+music+microphone) ? If yes, how can one solve it?
Not really an answer, but too long for a comment.
Guess you should take a look at MediaRecorder here and the android.permission.RECORD_AUDIO permission. But MediaRecorder is only working with MediaPlayer. So if you are using Exoplayer or similar it's not a solution. Be aware, that this might not work on all hardware devices and with all Android Versions (I think you should test with Android 10 first)!
Be aware of AudioFocusManager on Android. If you start the camera, it will request the AudioFocus, so other music apps on your device will stop playing music if you request the camera with sound. (There are differences between Android 10 and below).
Furthermore, camera is using device microphone, so I think recording microphone and camera input at the same time might not work, but you can always use the video-sound in this case.

Preventing other camera apps from using the camera when my app is using it

Will it be possible to prevent other camera app from using the camera while my app is using it, at least until the duration of my video recording is completed?
If yes, how can I achieve it?
If no, is there any event I can listen to to know if other camera app has accessed the camera?
What's happening is that the camera instance is being taken from my app and no video is being fed to the recorded file, only audio.

Camera gets locked randomly Android

I am using Media Recorder to record videos in background without displaying a preview at one of my Activities. It works fine but randomly the camera gets locked and the only way to unlock it is to re-start the phone.
Can we find whether the camera is locked?
How can it be unlocked?
In case the App crashes how can the camera be released?
mCamera.startPreview();
Sometimes the code stops at the above line of code and finally ANR is displayed.

Categories

Resources