Get noticed when other app tries to access camera on Android - android

I am working on the app that uses camera and mic in background mode. Obviously, when my app is active other camera apps (like Camera) will not work as the camera is held by my app.
Is there any way to get notified when the other app tries to open camera (if the camera is held by my app)?
I want my app to show some popup or notification when any other app tries to get camera (I think it will be more user-friendly to show some notice then to rely on other app's error messages)

Related

How to check if an Android app started by a service in a separate Android app has finished loading?

I am using the code below to start an installed camera app (not developed by me) from a background service in an app I'm working on.
Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.sec.android.app.camera");
startActivity( launchIntent );
I need to determine if the camera app is done loading and ready to use so I can prompt the camera to take a picture. After the picture is taken, my app will be brought back to the foreground and show a screensaver until the camera is started again or brought back to the foreground to take another picture. Is there a way to verify that the camera app is loaded and ready each time before attempting to send it commands?
For clarity, I'm not asking about how to check this on a camera app specifically. I'm trying to learn how I can start just about any app (not developed by me) and listen for it to be completely loaded and ready.
I am using the code below to start an installed camera app (not developed by me) from a background service
Launching activities from the background is not supported on modern versions of Android.
Also note that many devices will not have that particular package.
I need to determine if the camera app is done loading and ready to use so I can prompt the camera to take a picture
There is no canonical definition of "done loading and ready to use". And, in general, there is no means for you to monitor the operations of another app, for privacy and security reasons.
Also, outside of accessibility services, in general, you have no means of telling a running app to do anything unless it has a specific API for that purpose. Even with accessibility services, I suspect that it will be difficult to come up with an approach that works no matter what the camera app is.
If, from the foreground, you want a camera app to take a picture, use ACTION_IMAGE_CAPTURE. Or, integrate camera functionality directly in your own app, such as via CameraX or other libraries.

Using FlashLight in appWidget and crashes when start app camera

I have an app widget that is a flashlight.
I turn on and turn off the flash inside a service.
When I turn off the Flash release the camera to be used from other applications.
Now if I have the flash on and open the camera application, the camera app stops because I'm still using the camera in my service.
As I can release the camera automatically or detect when you want to be used from another application?
Note : I am developing for api 16-22

How to log the history of opening camera in Android

I am Developing an android application that should record the change state of the camera device in my phone in which every time I open the camera from any other application in my phone this application should save that application "X" open the camera at time "Y" and so on.
I have reached in my code to record the time that the camera was opened and close but I could not figure out how to discover the program name who has held the camera.
You could check the job queue from your BroadcastReceiver and see what is the current app.
related topic

Launch Google Camera or Default Camera over lock screen

I would like to learn more about how the camera can launch over the secure lock-screen (PIN).
My goal is to have a user select either their default camera app or another camera app (like Google Camera). I would then like to invoke or launch the camera without the user being required to enter their pin code, etc.
I have read that this is possible starting with Android 4.2.
Here is the post:
Launch camera activity over lock screen
Currently in my test build the camera app launches, but the user my first unlock the device.
Any help is appreciated.
Thank you.

how to start my application autiomaticaly in background when user launches a build-in camera on Android

I want to write application on Android that starts in background when user launches a built-in camera (it is important: build-in camera, not an application) and do some actions after user makes a photo.
Is it real? If yes, how to implement this?
I doubt if this is possible. There is no mechanism which android provides that causes a broadcast to the system that Camera has been launched. Plus, you cannot modify the contents shown on the screen as the Camera application is in command. The only way out is to have a MediaScanner and FileObserver to check when a new picture is created in DCIM/Camera/ folder and make your app act accordingly

Categories

Resources