public void setupScanner() {
    mScanner = new ImageScanner();
    mScanner.setConfig(0, Config.X_DENSITY, 3);
    mScanner.setConfig(0, Config.Y_DENSITY, 3);

    int[] symbols = getIntent().getIntArrayExtra(SCAN_MODES);
    if (symbols != null) {
      mScanner.setConfig(Symbol.NONE, Config.ENABLE, 0);
      for (int symbol : symbols) {
        mScanner.setConfig(Symbol.QRCODE, Config.ENABLE, 1);
        // mScanner.setConfig(symbol, Config.ENABLE, 1);
      }
    }
  }
Esempio n. 2
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_camera);

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    mContext = CameraActivity.this;

    mUsersSQL = "select a.[CORPNO], a.[OPERNO], a.[OPERPASS] from b_opera a;";
    mSearchUsersSQL = "select count(*) from b_opera a where a.[CORPNO] = ? and a.[OPERNO] = ?;";
    mInsertOperaSQL = "INSERT INTO B_OPERA (CORPNO, OPERNO, OPERPASS) VALUES(?, ?, ?, ?, ?);";
    mInsertDownInfoSQL =
        "INSERT INTO B_LOGININFO (CORPNO, PROJDESC, DOWNURL, UPLOADURL, DBFILENAME, DOWNTIME) VALUES(?, ?, ?, ?, ?, ?);";
    mDownLoadInfoSQL =
        "select a.[CORPNO], a.[PROJDESC], a.[DOWNURL], a.[UPLOADURL], a.[DBFILENAME] from b_logininfo a;";
    autoFocusHandler = new Handler();
    mCamera = getCameraInstance();

    /* Instance barcode scanner */
    scanner = new ImageScanner();
    scanner.setConfig(0, Config.X_DENSITY, 3);
    scanner.setConfig(0, Config.Y_DENSITY, 3);

    Log.i(TAG, "CameraActivity onCreate()");
    mPreview = new CameraPreview(this, mCamera, previewCb, autoFocusCB);
    FrameLayout preview = (FrameLayout) findViewById(R.id.cameraPreview);
    preview.addView(mPreview);

    mCamera.setPreviewCallback(previewCb);
    mCamera.startPreview();
    previewing = true;
    mCamera.autoFocus(autoFocusCB);

    // 初始化声音和震动
    AudioManager audioService = (AudioManager) getSystemService(AUDIO_SERVICE);
    // 如果手机是震动模式就震动
    if (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) {
      playBeep = false;
    }
    // 初始化声音
    initBeepSound();
    initLoginDataBase();
    // MyApp.showToast(CameraActivity.this, "hello");

    Button mButtonBack = (Button) findViewById(R.id.button_back);

    /*返回按钮*/
    mButtonBack.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            Intent intent = new Intent();
            intent.putExtra("downloadfile", "");
            setResult(RESULT_OK, intent);
            finish();
          }
        });
  }
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    vibrator = (Vibrator) getActivity().getSystemService(Context.VIBRATOR_SERVICE);

    scanner = new ImageScanner();
    scanner.setConfig(0, Config.X_DENSITY, 3);
    scanner.setConfig(0, Config.Y_DENSITY, 3);
  }
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    barcodeScanned = false;
    previewing = true;
    setContentView(R.layout.activity_scan);

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    autoFocusHandler = new Handler();
    mCamera = getCameraInstance();

    /* Instance barcode scanner */
    scanner = new ImageScanner();
    scanner.setConfig(0, Config.X_DENSITY, 3);
    scanner.setConfig(0, Config.Y_DENSITY, 3);

    mPreview = new CameraPreview(this, mCamera, previewCb, autoFocusCB);
    FrameLayout preview = (FrameLayout) findViewById(R.id.cameraPreview);
    preview.addView(mPreview);

    scanText = (TextView) findViewById(R.id.scanText);

    scanButton = (Button) findViewById(R.id.ScanButton);
    scanButton.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            if (barcodeScanned) {
              barcodeScanned = false;
              scanText.setText("Scanning...");
              mCamera.setPreviewCallback(previewCb);
              mCamera.startPreview();
              previewing = true;
              mCamera.autoFocus(autoFocusCB);
            }
          }
        });
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); // To avoid screen timeout

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    autoFocusHandler = new Handler();
    mCamera = getCameraInstance();

    /* Instance barcode scanner */
    scanner = new ImageScanner();
    scanner.setConfig(0, Config.X_DENSITY, 3);
    scanner.setConfig(0, Config.Y_DENSITY, 3);

    mPreview = new CameraPreview(this, mCamera, previewCb, autoFocusCB);
    FrameLayout preview = (FrameLayout) findViewById(R.id.cameraPreview);
    preview.addView(mPreview);

    // scanText = (TextView) findViewById(R.id.scanText);

    /*
    quitButton = (Button) findViewById(R.id.quitButton);

    quitButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            sp = getSharedPreferences(String.valueOf(storagePreference.admin_id), Context.MODE_PRIVATE);
            ed = sp.edit();
            ed.clear();
            ed.commit();

            android.os.Process.killProcess(android.os.Process.myPid());
            System.exit(1);
        }
    });


    adminLoginButton = (Button) findViewById(R.id.adminLoginButton);
    adminLoginButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent myIntent = new Intent(MainActivity.this, AdminLogin.class);
            startActivity(myIntent);
        }
    });
    */

    /*
    scanButton = (Button) findViewById(R.id.ScanButton);

    scanButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (barcodeScanned) {
                barcodeScanned = false;
                scanText.setText("Hold over barcode.");
                mCamera.setPreviewCallback(previewCb);
                mCamera.startPreview();
                previewing = true;
                mCamera.autoFocus(autoFocusCB);
            }
        }
    });
    */

  }