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

Transferring data via Bluetooth

We can transfer data to another device directly without having to use the Internet or any network infrastructure outside another device. Bluetooth allows one device to directly communicate with another device.

How to do it...

We can set up our app to listen for Bluetooth devices that we can communicate with:

  1. As with normal Bluetooth access, we need to have the apropriate permissions, such as Bluetooth and BluetoothAdmin, before we can transmit data via Bluetooth:
    [assembly: UsesPermission(Manifest.Permission.Bluetooth)]
    [assembly: UsesPermission(Manifest.Permission.BluetoothAdmin)]
  2. Before we start the listener, we need to have a name that will be used to register it with the system:
    const string ServiceName = "XamarinCookbookBluetooth"; ...

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