@Override
 public void onPause() {
   super.onPause();
   try {
     cameraView.stopCamera();
     stopAutofocus();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
 private void startAutofocus() {
   if (isHaveAutoFocus()) {
     autoFocusHandler.postDelayed(runAutoFocus, AUTOFOCUS_REFRESH_DELAY);
     cameraView.getCamera().autoFocus(autoFocusCallback);
   }
 }
 private void stopAutofocus() {
   if (isHaveAutoFocus() && cameraView.getCamera() != null) {
     autoFocusHandler.removeCallbacks(runAutoFocus);
     cameraView.getCamera().cancelAutoFocus();
   }
 }