private void Init() { _context = this; // _app = (App)Application; _rfidManager = HoneywellDeviceHub.GetInstance().RfidMgr; _bTSeartTv = (Button)FindViewById(Resource.Id.btn_search); _lvBleScan = (ListView)FindViewById(Resource.Id.bt_list); _accessReadBtn = (Button)FindViewById(Resource.Id.access_read); _bluetoothAdapter = BluetoothAdapter.DefaultAdapter; _bTSeartTv.SetOnClickListener(this); _bTSeartTv.Enabled = true; _accessReadBtn.SetOnClickListener(this); _bleScanListAdapter = new BluetoothDeviceListAdapter(this, ref _bleScanDevices); _lvBleScan.Adapter = _bleScanListAdapter; _lvBleScan.OnItemClickListener = this; _progressDialog = new ProgressDialog(this); _progressDialog.SetMessage(GetString(Resource.String.loading_text)); _connectionHandler = new BtConnectionHandler(this); _leScanCallback = new BleScanCallBack(_connectionHandler); _btReceiver = new BtReceiver(); _btReceiver.OnBtStateChange += _btReceiver_OnBtStateChange; IntentFilter filter = new IntentFilter(); filter.AddAction("android.bluetooth.adapter.action.STATE_CHANGED"); RegisterReceiver(_btReceiver, filter); }
private void Init() { _context = this; _app = (App)Application; _rfidMgr = _app.RfidMgr; _view = FindViewById(Resource.Id.group); _bTSwitch = (Switch)FindViewById(Resource.Id.bt_switch); _autoConnectSwitch = (Switch)FindViewById(Resource.Id.auto_connect_switch); _bTSeartTv = (TextView)FindViewById(Resource.Id.btn_search); _lvBleScan = (ListView)FindViewById(Resource.Id.bt_list); AccessReadBtn = (Button)FindViewById(Resource.Id.access_read); _bluetoothAdapter = BluetoothAdapter.DefaultAdapter; _bTSeartTv.SetOnClickListener(this); AccessReadBtn.SetOnClickListener(this); _bTSwitch.Checked = _bluetoothAdapter.IsEnabled; _bTSwitch.CheckedChange += _bTSwitch_CheckedChange; var sp = this.GetSharedPreferences(SP_NAME, FileCreationMode.Private); bool autoConnectState = sp.GetBoolean(SP_KEY_AUTO_CONNECT, false); _autoConnectSwitch.Checked = autoConnectState; _autoConnectSwitch.CheckedChange += _autoConnectSwitch_CheckedChange; // _test.Add(new ViewHolder()); BleScanListAdapter = new BluetoothDeviceListAdapter(this, ref _bleScanDevices); _lvBleScan.Adapter = BleScanListAdapter; _lvBleScan.OnItemClickListener = this; _lvBleScan.OnItemLongClickListener = this; _progressDialog = new ProgressDialog(this); _progressDialog.SetMessage(GetString(Resource.String.loading_text)); ConnectionHandler = new BtConnectionHandler(this); _leScanCallback = new BleScanCallBack(ConnectionHandler); SetVisibility(); _btReceiver = new BtReceiver(); _btReceiver.OnBtStateChange += _btReceiver_OnBtStateChange; IntentFilter filter = new IntentFilter(); filter.AddAction("android.bluetooth.adapter.action.STATE_CHANGED"); RegisterReceiver(_btReceiver, filter); }
public BleScanCallBack(BtConnectionHandler handler) { _btConnectionHandler = handler; }