Пример #1
0
        // <summary>
        // The onCreate method called to create the view Find the views and set an on click listener on the button
        // </summary>
        // <param name="savedInstanceState">savedInstanceState</param>
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.main_activity);
            _deviceService = MyDeviceService.Instance(new Robotics.Mobile.Core.Bluetooth.LE.Adapter());
            _devices       = new List <Device> ();

            _connectToDevice = FindViewById <Button> (Resource.Id.connect_to_device);
            _connectToDevice.SetOnClickListener(this);
            _searchForDevices = FindViewById <Switch> (Resource.Id.search_for_devices);
            _searchForDevices.SetOnCheckedChangeListener(this);

            _nearDevices    = FindViewById <Spinner> (Resource.Id.near_devices);
            _spinnerAdapter = new ArrayAdapter <string> (this, Android.Resource.Layout.SimpleSpinnerItem, Android.Resource.Id.Text1);
            _spinnerAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            _nearDevices.Adapter = _spinnerAdapter;
            InitEmptyLists();
        }
        // <summary>
        // The onCreate method called to create the view Find the views and set an on click listener on the button
        // </summary>
        // <param name="savedInstanceState">savedInstanceState</param>
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.sensor_control_activity);

            _ambientTemperature = FindViewById <TextView> (Resource.Id.ambient_temperatur);
            _targetTemperature  = FindViewById <TextView> (Resource.Id.target_temperature);
            _accelerometerX     = FindViewById <TextView> (Resource.Id.accelerometer_x);
            _accelerometerY     = FindViewById <TextView> (Resource.Id.accelerometer_y);
            _accelerometerZ     = FindViewById <TextView> (Resource.Id.accelerometer_z);
            _humidity           = FindViewById <TextView> (Resource.Id.humidity);
            _magnetometerX      = FindViewById <TextView> (Resource.Id.magnetometer_x);
            _magnetometerY      = FindViewById <TextView> (Resource.Id.magnetometer_y);
            _magnetometerZ      = FindViewById <TextView> (Resource.Id.magnetometer_z);

            _sensorService = MyDeviceService.Instance(new Robotics.Mobile.Core.Bluetooth.LE.Adapter());

            _sensorService.ConnectToDevice(SensorValueChanged);
        }