O'Reilly logo

Xamarin Mobile Development for Android Cookbook by Matthew Leibowitz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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:

  1. As with most hardware services, we need to request permission to access Bluetooth:
    [assembly: UsesPermission(Manifest.Permission.Bluetooth)]
  2. If we want to directly control the Bluetooth hardware, we need to specify an additional permission:
    [assembly: UsesPermission(
      Manifest.Permission.BluetoothAdmin)]
  3. Once we have the permissions we need, we obtain ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required