private void startCameraSource() {
   try {
     mPreview.start(mCameraSource, mGraphicOverlay);
     boolean startAsyncTask = sp.getBoolean("vision_continuous_test", false);
     if (!startAsyncTask) {
       if (asyncTask != null) {
         // Check if there is an Async Task running. If so, cancel it
         switch (asyncTask.getStatus()) {
           case RUNNING:
             asyncTask.cancel(true);
             asyncTask = null;
             break;
           case PENDING:
             asyncTask.cancel(true);
             asyncTask = null;
             break;
           case FINISHED:
             asyncTask = null;
             break;
         }
       }
       asyncTask =
           new AsyncTaskWaitForBarcode(
                   this, Integer.parseInt(sp.getString("vision_sleep", "1500")))
               .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
     }
   } catch (IOException e) {
     mCameraSource.release();
     mCameraSource = null;
   }
 }
 @Override
 protected void onPause() {
   super.onPause();
   mPreview.stop(); // stop
 }