protected override void OnResume()
        {
            base.OnResume();

            Log.Info(LOGTAG, "OnResume");

            // If the decoder instance is null, create it.
            if (decoder == null)
            {
                // Remember an onPause call will set it to null.
                decoder = new BarcodeManager();
            }

            // From here on, we want to be notified with exceptions in case of errors.
            ErrorManager.EnableExceptions(true);

            try
            {
                // add our class as a listener
                decoder.AddReadListener(this);
            }
            catch (DecodeException e)
            {
                Log.Error(LOGTAG, "Error while trying to bind a listener to BarcodeManager", e);
            }
        }
        override protected void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Create a BarcodeManager.
            manager = new BarcodeManager();
            SetContentView(Resource.Layout.Main);

            // setup button
            Button btn = (Button)FindViewById(Resource.Id.button1);

            btn.Click += delegate
            {
                StartSettingsActivity();
            };

            // Pass it to ScannerProperties class.
            // ScannerProperties cannot be instatiated directly, instead call edit.
            configuration = ScannerProperties.Edit(manager);

            // Now we can change some Scanner/Device configuration parameters.
            // These values are not applied, as long as store method is not called.
            configuration.Code39.Enable.Set(true);
            configuration.Code39.EnableChecksum.Set(true);
            configuration.Code39.FullAscii.Set(true);
            configuration.Code39.Length1.Set(20);
            configuration.Code39.Length2.Set(2);
            configuration.Code39.LengthMode.Set(LengthControlMode.TwoFixed);
            configuration.Code39.SendChecksum.Set(false);
            configuration.Code39.UserID.Set('x');

            configuration.Code128.Enable.Set(true);
            configuration.Code128.Length1.Set(6);
            configuration.Code128.Length2.Set(2);
            configuration.Code128.LengthMode.Set(LengthControlMode.Range);
            configuration.Code128.UserID.Set('y');

            if (configuration.QrCode.IsSupported)
            {
                configuration.QrCode.Enable.Set(false);
            }

            // Change IntentWedge action and category to specific ones.
            configuration.IntentWedge.Action.Set("com.datalogic.examples.decode_action");
            configuration.IntentWedge.Category.Set("com.datalogic.examples.decode_category");

            // From here on, we would like to get a return value instead of an exception in case of error
            ErrorManager.EnableExceptions(false);

            // Now we are ready to store them
            // Second parameter set to true saves configuration in a permanent way.
            // After boot settings will be still valid.
            int errorCode = configuration.Store(manager, true);

            // Check return value.
            if (errorCode != ConfigException.Success)
            {
                Log.Error(LOGTAG, "Error during store", ErrorManager.LastError);
            }
        }
Example #3
0
        //called when the activity is created
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_reset);

            ErrorManager.EnableExceptions(true);

            try
            {
                pm = new Com.Datalogic.Device.Power.PowerManager();
            }
            catch (DeviceException exception)
            {
                Log.Error(this.GetType().Name, "While creating ResetActivity");
            }
            //set listArray with types of device resetting
            setArray();
            //create an array adapter which will hold our data for our ListView
            ArrayAdapter <Object> adapter = new ArrayAdapter <object>(this, Android.Resource.Layout.SimpleListItem1, listArray);

            //create our list view
            listReset = (ListView)FindViewById(Resource.Id.listReset);
            //set it's adapter to be our custom adapter we just created
            listReset.Adapter = adapter;
            //Here we set the event handler that is called when an item in our List View is clicked
            listReset.ItemClick += resetEventHandler;
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_notification);

            ErrorManager.EnableExceptions(true);

            try
            {
                //create a new LedManager which is responsible for everything related to LED
                led = new LedManager();
            } catch (Exception e)
            {
                Log.Error(this.GetType().Name, "Error while creating LedManager");
            }

            //this button will cause the LED to blink a set number of times
            btnLed = (Button)FindViewById(Resource.Id.btnLed);
            //wire up our event handler for when the button is clicked
            btnLed.Click += BtnLedBlinkClicked;
            //this button will cause the LED to turn on or off
            btnLedEnable = (Button)FindViewById(Resource.Id.btnLedEnable);
            //wire up our event handler for when the button is clicked
            btnLedEnable.Click += BtnLedEnableClicked;
            //this method will initially turn the LED on.
            TurnOnGreenSpotLed();
        }
        private void MyClickedItemListener(object sender, RadioGroup.CheckedChangeEventArgs e)
        {
            // Handle errors through java Exceptions
            ErrorManager.EnableExceptions(true);

            try
            {
                // get the current settings from the BarcodeManager
                configuration = ScannerProperties.Edit(manager);
                // disables KeyboardWedge
                configuration.KeyboardWedge.Enable.Set(false);
                // enable wedge intent
                configuration.IntentWedge.Enable.Set(true);

                switch (e.CheckedId)
                {
                case Resource.Id.radioBroadcast:
                    // set wedge intent action and category
                    configuration.IntentWedge.Action.Set(ACTION_BROADCAST_RECEIVER);
                    configuration.IntentWedge.Category.Set(CATEGORY_BROADCAST_RECEIVER);
                    // set wedge intent delivery through broadcast
                    configuration.IntentWedge.DeliveryMode.Set(IntentDeliveryMode.Broadcast);
                    configuration.Store(manager, false);
                    break;

                case Resource.Id.radioStartActivity:
                    // set wedge intent action and category
                    configuration.IntentWedge.Action.Set(ACTION);
                    configuration.IntentWedge.Category.Set(CATEGORY);
                    // intent delivery startActivity
                    configuration.IntentWedge.DeliveryMode.Set(IntentDeliveryMode.StartActivity);
                    configuration.Store(manager, false);
                    break;
                }
            }
            catch (Exception exception) //catch any errors that occured.
            {
                if (exception is ConfigException)
                {
                    ConfigException ex = (ConfigException)exception;
                    Log.Info(this.GetType().Name, "Error while retrieving/setting properties:" + exception.Message);
                }
                else if (exception is DecodeException)
                {
                    DecodeException ex = (DecodeException)exception;
                    Log.Info(this.GetType().Name, "Error while retrieving/setting properties:" + exception.Message);
                }
                else
                {
                    Log.Info(this.GetType().Name, "Error while retrieving/setting properties:" + exception.Message);
                }
            }
        }
        /**
         * Enable or disable Nfc, using com.datalogic.device.nfc.NfcManager.
         */
        public void SetEnableNfc(bool enable)
        {
            bool previous = ErrorManager.AreExceptionsEnabled();

            ErrorManager.EnableExceptions(false);
            ErrorManager.ClearErrors();

            int error = new Com.Datalogic.Device.Nfc.NfcManager().EnableNfcAdapter(enable);

            if (error != DeviceException.Success)
            {
                Log.Error(this.LocalClassName, "Error while setting NFC", ErrorManager.LastError);
            }
            ErrorManager.EnableExceptions(previous);
        }
        /**
         * Use LocationManager to set the gps as enabled (true), or disabled
         * (false).
         */
        public void SetGPSState(bool enable)
        {
            LocationManager gps = null;

            // Store previous exception preference.
            bool previous = ErrorManager.AreExceptionsEnabled();

            // We want to be notified through an exception if something goes wrong.
            ErrorManager.EnableExceptions(true);
            try
            {
                gps = new LocationManager();
                gps.SetLocationMode(enable ? LocationMode.SensorsAndNetwork : LocationMode.Off);
            }
            catch (DeviceException e1)
            {
                // Just in case we get an error.
                Log.Error(this.LocalClassName, "Exception while switching location mode ", e1);
            }
            // Set previous value.
            ErrorManager.EnableExceptions(previous);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_sleep);
            //set ErrorManager to all exceptions
            ErrorManager.EnableExceptions(true);

            try
            {
                //create our PowerManager for later use
                pm = new Com.Datalogic.Device.Power.PowerManager();
            } catch(DeviceException exception)
            {
                Log.Error(this.GetType().Name, "While creating activity"); //TODO IN ANDROID VERSION THIS PASSES IN THE EXCEPTION THROWN...HOW DO THAT IN XAMARIN
            }
            //this will hold our sleeping configuration data
            txtSleep = (TextView)FindViewById(Resource.Id.txtSleep);
            //load available timeouts
            setTimeouts();
            //load wakeup sources
            setSources();

            //here we create an array adapter which we will use to hold our timouts avaiable for each source
            ArrayAdapter<String> timeoutAdapter = new ArrayAdapter<String>(this, Android.Resource.Layout.SimpleListItem1, timeouts);
            //Here we create an array adapter which we will use to hold our sources avaialable which will be used with the timeouts
            ArrayAdapter<String> sourceAdapter = new ArrayAdapter<String>(this, Android.Resource.Layout.SimpleListItem1, sources);

            //create our timeout list view, set our adapter for our timeouts and wire up our event handler
            listSuspendTimeout = (ListView)FindViewById(Resource.Id.listSuspendTimeout);
            listSuspendTimeout.Adapter = timeoutAdapter;
            listSuspendTimeout.ItemClick += TimeoutListListener;
            //create our sources list view, set our adapter for our sources, and wire up our event handler
            listWakeupSource = (ListView)FindViewById(Resource.Id.listWakeupSource);
            listWakeupSource.Adapter = sourceAdapter;
            listWakeupSource.ItemClick += SourceListListener;


        }