I\'m trying the camera preview on my Android applications. When I try on my real devices, it gives me black screen.
This is my code and it doesn\'t throw any error,
Bit of an odd issue I've just found relating to black camera preview. In my case it turned out to be because I had the manifest options
PARTIAL_WAKE_LOCK and also REQUEST_INSTALL_PACKAGES
<uses-permission android:name="android.permission.PARTIAL_WAKE_LOCK"/>
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>
Why these affect the camera like this I don't know - or whether it's just related to the device I'm using - but removing these permissions resolved my issue. It's taken me 2 hours of stripping a project down to figure out where the issue came in!
Maybe you are being affected by this bug of android Camera bug.
The workaround to which is proposed here Work around.
I hope it helps..
Also refer this Link
You are calling the last three lines too early. You have to wait for the surface to be prepared before calling setPreviewDisplay() and you have to wait for the surface to be sized (surfaceChanged()) before calling startPreview(). This project has what you need.