コード例 #1
0
 public void setAutoFocus(boolean state) {
   if (mCamera != null && mPreviewing) {
     if (state == mAutoFocus) {
       return;
     }
     mAutoFocus = state;
     if (mAutoFocus) {
       if (mSurfaceCreated) { // check if surface created before using autofocus
         Log.v(TAG, "Starting autofocus");
         safeAutoFocus();
       } else {
         scheduleAutoFocus(); // wait 1 sec and then do check again
       }
     } else {
       Log.v(TAG, "Cancelling autofocus");
       mCamera.cancelAutoFocus();
     }
   }
 }
コード例 #2
0
 public void showCameraPreview() {
   if (mCamera != null) {
     try {
       mPreviewing = true;
       setupCameraParameters();
       mCamera.setPreviewDisplay(getHolder());
       mCamera.setDisplayOrientation(getDisplayOrientation());
       mCamera.setOneShotPreviewCallback(mPreviewCallback);
       mCamera.startPreview();
       if (mAutoFocus) {
         if (mSurfaceCreated) { // check if surface created before using autofocus
           safeAutoFocus();
         } else {
           scheduleAutoFocus(); // wait 1 sec and then do check again
         }
       }
     } catch (Exception e) {
       Log.e(TAG, e.toString(), e);
     }
   }
 }
コード例 #3
0
 public void run() {
   if (mCamera != null && mPreviewing && mAutoFocus && mSurfaceCreated) {
     safeAutoFocus();
   }
 }