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
NfcBookCh9Example4and package named
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.xmlfile is correctly configured. Refer to the Requesting NFC permissions recipe in Chapter 1, Getting Started with NFC.
NfcHelper.javaclass into the project.
Request for permission to administrate Bluetooth...