Accessing Bluetooth
Data sometimes needs to be transferred to another device, but to one where there is no network infrastructure. We may therefore want to integrate Bluetooth into our app to transfer data or to interact with various devices that cannot be accessed via the Internet or a local network.
How to do it...
To interact with the various Bluetooth services, we need the BluetoothAdapter
instance:
- As with most hardware services, we need to request permission to access Bluetooth:
[assembly: UsesPermission(Manifest.Permission.Bluetooth)]
- If we want to directly control the Bluetooth hardware, we need to specify an additional permission:
[assembly: UsesPermission( Manifest.Permission.BluetoothAdmin)]
- Once we have the permissions we need, we obtain ...
Get Xamarin Mobile Development for Android Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.