7

I am developing an app that take pictures from camera object and save it to the sdcard. It works great except some things.(I cant config some parameters for example resolution). But when I take picture it freeze on the screen. I just want to resume the preview and capturing same way after I take picture. here is the full code : http://bahacanaydin.blogspot.com/2012/05/package-com.html

baha
  • 99
  • 2
  • 11

3 Answers3

13

You have to put mCamera.startPreview(); inside your onPictureTaken() function to restart preview again, because it stops automatically when the picture is taken.

lenik
  • 23,228
  • 4
  • 34
  • 43
  • That's true. the preview starts again when I locate the mCamera.startPreview(); in onPictureTaken() function but I cant capture again , program force close – baha May 15 '12 at 10:30
3

Maybe this will help. From Android SDK documentation on takePicture():

After calling this method, you must not call startPreview() or take another picture until the JPEG callback has returned.

The JPEG callback is implementation of onPictureTaken(), as I understand. So you should defer your call to startPreview.

viskin
  • 493
  • 4
  • 15
0
mCamera.takePicture(null, null, mPicture);
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
//Do something after 1000ms
       mCamera.startPreview();
           }
     }, 1000);
mojtaba
  • 94
  • 1
  • 4