Bluetooth is a well-known wireless communication standard and almost all phones embed a Bluetooth controller. In this recipe, we'll connect ourselves to a Bluetooth object and send/receive data from it.
To follow this recipe, create a new project called
Bluetooth, and you'll need to deploy your application on a physical phone as the emulator doesn't support Bluetooth. Also, you'll need to bond your phone to the target Bluetooth device of your choice—using the Bluetooth Manager of Android—prior to launching the app.
Here are the steps to complete this recipe:
Java.Utilat the top of your
MainActivityclass. In addition, you will need the Bluetooth permissions.