You're getting NullPointerException on line 40, which is:
final Parameters p = camera.getParameters();
Most likely the camera
object is null. You're initializing it earlier with:
camera = Camera.open();
and Camera.open():
Creates a new Camera object to access the first back-facing camera on the device. If the device does not have a back-facing camera, this returns null.
Check if your camera is not null and proceed only then, eg.:
camera = Camera.open();
if (camera != null) {
//normal code
}
else {
//ERROR, camera is null
}
You might be getting this because:
- the device does not have back-facing camera
you forgot to add
<uses-permission android:name="android.permission.CAMERA" />
in your AndroidManifest.