In the Inviting a friend to play a game – Part 1 recipe in Chapter 7, Sharing Content across Devices, we were able to share Bluetooth information between two devices. In Part 2, we will use that information to connect the devices and start a noughts and crosses game.
We will use the BluetoothService
class to handle Bluetooth communication and send simple text messages between the devices:
Open Eclipse and create a new Android application project named
NfcBookCh9Example4
and package namednfcbook.ch9.example4
.Import the files from the Inviting a friend to play a game – Part 1 recipe in Chapter 7, Sharing Content across Devices, or if preferred, continue following this recipe in the same project.
Make sure the
AndroidManifest.xml
file is correctly configured. Refer to the Requesting NFC permissions recipe in Chapter 1, Getting Started with NFC.Import the
NfcHelper.java
class into the project.Request for permission to administrate Bluetooth...