Reputation: 913
I am writing an Android application that uses the v1 Camera API to stream the preview frames. It needs to be able to get the preview frames even if it is not in the foreground. So far I've gotten everything to work just fine. (For instance, if navigate to the home screen, my application still receives preview frames). However, it appears that camera.lock()
is not working correctly, because if I open another app that uses the camera (the default camera app for instance) then my application stops receiving preview frames, and the camera app successfully opens the camera. According to the documentation if I have locked the camera, another process should not be able to use it. Interestingly, the flashlight button on the notification shade is greyed out while my app is running in the background. It seems like the flashlight code is correctly being locked out, but not the default camera app. Anyone have some insight on this?
Upvotes: 0
Views: 86
Reputation: 381
The camera.lock
API is designed for video recording use case where the application and MediaRecorder both have access to the Camera
object.
For the scenario you pointed out, the Android camera framework will always allow foreground application to open camera successfully (and force closing the camera object of the other application that's not in foreground anymore). This is to avoid one (ill-written or malicious) application to block camera access for all other applications.
Upvotes: 1