protected override void OnStop() { base.OnStop(); ble.StopScanner(); ble.Dispose(); ble = null; }
protected override void OnResume() { base.OnResume(); ble = new BluetoothScanner(this, this, this); ble.ScanResultEvent += Ble_ScanResultEvent; mListView = FindViewById <ListView>(Resource.Id.listView1); adapterList = new DeviceAdapter(this, ble.mLeDevices); mListView.Adapter = adapterList; mListView.ItemClick += MListView_ItemClick; if (ble.mBluetoothAdapter != null) { if (!ble.mBluetoothAdapter.IsEnabled) { if (flag_connessioneBLE) { Intent enableBtIntent = new Intent(BluetoothAdapter.ActionRequestEnable); StartActivityForResult(enableBtIntent, 2); } } else { ble.Scanner(); } } else { Handler mHandler = new Handler(); mHandler.PostDelayed(new Action(delegate { Finish(); }), 2500); Toast.MakeText(this, "BLE Not Supported!", ToastLength.Short).Show(); } }