private void InitScan()
        {
            var integrator = new IntentIntegrator(this);

            integrator.SetPrompt("请扫描");
            integrator.SetOrientationLocked(true);
            integrator.SetCameraId(0);
            integrator.SetBeepEnabled(false);
            integrator.SetCaptureActivity(new ScanActivity().Class);
            integrator.InitiateScan();
        }
Ejemplo n.º 2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            LinearLayout ll     = new LinearLayout(this);
            Button       button = new Button(this);

            button.Text   = "Click to Scan using Zxing";
            button.Click += (s, e) =>
            {
                IntentIntegrator intentIntegrator = new IntentIntegrator(this);
                intentIntegrator.InitiateScan();
            };
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(Android.Views.ViewGroup.LayoutParams.MatchParent,
                                                                         Android.Views.ViewGroup.LayoutParams.WrapContent);
            ll.AddView(button, lp);
            SetContentView(ll);
        }
        protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);
            IntentResult result = IntentIntegrator.ParseActivityResult(requestCode, (int)resultCode, data);

            if (result != null)
            {
                if (result.Contents == null)
                {
                    textView1.Text = "No Result.";
                    Toast.MakeText(this, "Cancelled", ToastLength.Long).Show();
                }
                else
                {
                    textView1.Text = result.Contents;
                    Toast.MakeText(this, "Scanned: " + result.Contents, ToastLength.Long).Show();
                }
            }
        }
Ejemplo n.º 4
0
        protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
        {
            IntentResult result = IntentIntegrator.ParseActivityResult(requestCode, (int)resultCode, data);

            if (result != null)
            {
                if (result.Contents == null)
                {
                    Log.Debug("MainActivity", "Cancelled scan");
                    Toast.MakeText(this, "Cancelled", ToastLength.Long).Show();
                }
                else
                {
                    Log.Debug("MainActivity", "Scanned");
                    Toast.MakeText(this, "Scanned: " + result.Contents, ToastLength.Long).Show();
                }
            }
            else
            {
                base.OnActivityResult(requestCode, resultCode, data);
            }
        }