I want to get notified whenever any other application opened or accessed camera. I already know that I can check Camera.open() and its exception. but for that I have to check every time using service but it drain battery so I want whenever opened camera just notified me and get its package name. I already read these.
How to find whether the camera is in use?
How to check if camera is opened by any application
You can do it using callbacks provided by the API of Camera2.
In your CameraManagerobject you can attach a CameraManager.AvailabilityCallback which will notice you when the camera object is being used or not.
About AvailabilityCallback:
A callback for camera devices becoming available or unavailable to open.
Cameras become available when they are no longer in use, or when a new removable camera is connected. They become unavailable when some application or service starts using a camera, or when a removable camera is disconnected.
You can research more information about it in the official documentation
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