protected override void OnResume()
 {
     myLog.doLog("OnCreate");
     base.OnResume();
     if (BarcodeReader == null)
     {
         BarcodeReader = new BarcodeIntent(ApplicationContext);
         BarcodeIntent.onBarcodeReadEvent += new BarcodeIntent.BarcodeReadHandler(onBarcode);
     }
 }
 protected override void OnPause()
 {
     myLog.doLog("OnPause");
     base.OnPause();
     if (BarcodeReader != null)
     {
         BarcodeIntent.onBarcodeReadEvent -= onBarcode;
         BarcodeReader.Dispose();
         BarcodeReader = null;
     }
 }
Exemplo n.º 3
0
            public override void OnReceive(Context context, Intent intent)
            {
                myLog.doLog("IntentApiSample: ", "onReceive");
                if (ACTION_BARCODE_DATA.Equals(intent.Action))
                {
                    /*
                     * These extras are available:
                     * "version" (int) = Data Intent Api version
                     * "aimId" (String) = The AIM Identifier
                     * "charset" (String) = The charset used to convert "dataBytes" to "data" string
                     * "codeId" (String) = The Honeywell Symbology Identifier
                     * "data" (String) = The barcode data as a string
                     * "dataBytes" (byte[]) = The barcode data as a byte array
                     * "timestamp" (String) = The barcode timestamp
                     */
                    int version = intent.GetIntExtra("version", 0);
                    if (version >= 1)
                    {
                        String aimId        = intent.GetStringExtra("aimId");
                        String charset      = intent.GetStringExtra("charset");
                        String codeId       = intent.GetStringExtra("codeId");
                        String data         = intent.GetStringExtra("data");
                        byte[] dataBytes    = intent.GetByteArrayExtra("dataBytes");
                        String dataBytesStr = "";
                        if (dataBytes != null && dataBytes.Length > 0)
                        {
                            dataBytesStr = myLog.bytesToHexString(dataBytes);
                        }
                        String timestamp = intent.GetStringExtra("timestamp");
                        String text      = String.Format(
                            "Data:{0}\n" +
                            "Charset:{1}\n" +
                            "Bytes:{2}\n" +
                            "AimId:{3}\n" +
                            "CodeId:{4}\n" +
                            "Timestamp:{5}\n",
                            data, charset, dataBytesStr, aimId, codeId, timestamp);

                        myLog.doLog(text);

                        //if(_scanner!=null)
                        BarcodeIntent.onBarcodeRead(new BarcodeReadEventArgs(aimId, charset, codeId, data, dataBytes, timestamp));
                    }
                }
            }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            myLog.doLog("OnCreate");
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.BarcodeReaderIN);
            btnScan        = (Button)FindViewById(Resource.Id.btnStartIntent);
            btnScan.Click += BtnScan_Click;
            btnStop        = (Button)FindViewById(Resource.Id.btnStopIntent);
            btnStop.Click += BtnStop_Click;
            text           = (TextView)FindViewById(Resource.Id.textView1);

            if (BarcodeReader == null)
            {
                BarcodeReader = new BarcodeIntent(ApplicationContext);
                BarcodeIntent.onBarcodeReadEvent += new BarcodeIntent.BarcodeReadHandler(onBarcode);

                //example of changing properties
                BarcodeReader.setProperty(IntentScannerProperties.PROPERTY_PDF_417_ENABLED, true);
            }
        }