protected override void OnCreate(Bundle bundle) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(bundle); global::Xamarin.Forms.Forms.Init(this, bundle); ////this.RegisterReceiver((BroadcastReceiver)this.bluetoothCommunicationHandler.GetDeviceDiscoveryBroadcastReceiver("HC-06"), new IntentFilter(BluetoothAdapter.ActionDiscoveryFinished)); // To make your device discoverable to other devices, use below code. ////Intent discoverableIntent = new Intent(BluetoothAdapter.ActionRequestDiscoverable); ////discoverableIntent.PutExtra(BluetoothAdapter.ExtraDiscoverableDuration, 300); ////StartActivity(discoverableIntent); // Generate an instance of the bluetooth communication handler which would be passed to the Xamarin code to be used for any bluetooth related operations. this.bluetoothCommunicationHandler = new BluetoothCommunicationHandler(this.RequestEnableBluetoothIntent); // Pass the bluetooth communication handler. this.LoadApplication(new App(this.bluetoothCommunicationHandler)); }
public BluetoothDeviceReceiver(Func <bool, string, BluetoothSocket, Task> onBluetoothDeviceConnected, string deviceNameToConnect, BluetoothCommunicationHandler bluetoothCommunicationHandler) { this.bluetoothDeviceConnected = onBluetoothDeviceConnected; this.deviceNameToConnect = deviceNameToConnect; this.bluetoothCommunicationHandler = bluetoothCommunicationHandler; }