Camera gets locked randomly Android - 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.

Related

Flutter Stops screen recording but the voice is still recorded

I just used flutter package flutter_windowmanager to stop screen recording and screenshots the app works properly but when i record screen it appears black screen but the voice is still running
i tried to stop screen recording it worked but the voice is still working
You can check this article for disabling the audio in Android:
Link of the article

MediaStore.ACTION_VIDEO_CAPTURE crashes app when playing recorded video from preview screen on Noughat devices

I am recording video using default camera using intent however, as soon as video is recorded preview screen is shown. I have not created preview screen. This is default screen of Android. On clicking play button, app is crashing without any error.
Below is the code:
Intent videoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
videoIntent.putExtra(MediaStore.EXTRA_DURATION_LIMIT,30);
videoIntent.putExtra("android.intent.extra.USE_FRONT_CAMERA", true);
startActivityForResult(videoIntent,REQUEST_CODE_VIDEO_CAPTURE);
No error is showing in logcat.
as soon as video is recorded preview screen is shown. I have not created preview screen. This is default screen of Android
Based on your code, that would be part of the camera app that you happen to be using.
On clicking play button, app is crashing without any error.
Apparently that particular camera app has a bug. This is not surprising.
Bear in mind that there are dozens of different camera apps that might respond to your ACTION_VIDEO_CAPTURE Intent, and that they are not required to pay attention to your android.intent.extra.USE_FRONT_CAMERA extra, as that is not part of the ACTION_VIDEO_CAPTURE protocol.

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.

How to use background camera and foreground camera simultaneously?

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?

How to keep recording video when device is locked?

I'm working on a video recording app designed to keep recording despite interruptions (phone calls, etc.). My use case would be a user in the app pushing a button on screen to start a recording, and then at some later time manually locking the phone. I'm trying to keep the app recording video even while the phone is locked.
On devices running earlier versions of Android (tested on Android 4.1, DROID 4), the video recording keeps going when the phone has been locked. Testing on various devices, I have been unable to get the video to continue recording on any Android version past 4.1. On devices past 4.1, the video stops recording, but the audio still continues recording, while the last video frame stays on screen.
Is there any way to keep the app recording when the user locks the phone?
Basically, lock screen does not affect the working of services in an application. So if you use a service, then your recording will proceed. check out this link for more information:
Android app video recording when screen off

Categories

Resources