I want to implement a functionality to capture image through front camera when someone tries to unlock my device and enter incorrect password 3 times. I checked that it is possi
I have tested your code and I get a proper image so I think your camera code works fine.
You can check my code here. I copied the CameraView class from yours. The device admin part I took from https://github.com/marakana/DevicePolicyDemo The picture is taken when the first attempt fails.
I doubt that it might be some kind of hardware issue. I am not sure if you've seen Taking picture from camera without preview.
The second answer there mentions that faking the preview with a dummy SurfaceView does not work on all Android devices. Please see his blog. He's done the test on various phones. You could try my project and if it doesn't work on your phone. This might be the case. (The other answers might also be useful for you.)
I tried my code on Galaxy S3 with CM10.
Hope this helps.
Edit1: Tested on HTC One, HTC One X, Sony Experia. Works fine.
Edit2: Worked on Galaxy Note.