I am using dummy surface in my code.It\'s working fine in Canvas HD running 4.2.1 but when the same app is deployed on my nexus 5/S 3 it gives RunTimeException on camera.tak
This is not possible, you need an activity to display the camera in.
Consider a transparent activity that just holds the camera view.
You shouldn't use a dummy SurfaceView as Android checks is the SurfaceView is displayed on the screen.
Instead, display the preview on a SurfaceView with WindowManager, with type SYSTEM_OVERLAY. Set your SurfaceView width and height to 1px and the opacity to 0 to hide the preview, and that's it!
If you plan to support only 5.0+ devices, or it's a new app that won't be available too soon, you should consider using the new android Camera2 API, which fixed many mistakes of the older API.
Hope it will help you :)
You can use a dummy SurfaceTexture instead of a SurfaceView. This is reliable and works fine on the old camera API:
mDummyTexture = new SurfaceTexture(1); // pick a random argument for texture id
mCamera.setPreviewTexture(mDummyTexture);
mCamera.startPreview();
mCamera.takePicture(...);
Just make sure to keep mDummyTexture as a member of your class, or you may get abandoned surface errors.
As long as you don't call SurfaceTexture#updateTexImage(), you do not need an OpenGL context.