Book Image

Near Field Communication with Android Cookbook

By : Vitor Subtil
Book Image

Near Field Communication with Android Cookbook

By: Vitor Subtil

Overview of this book

Table of Contents (17 chapters)
Near Field Communication with Android Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Inviting a friend to play a game – Part 2


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.

How to do it...

We will use the BluetoothService class to handle Bluetooth communication and send simple text messages between the devices:

  1. Open Eclipse and create a new Android application project named NfcBookCh9Example4 and package named nfcbook.ch9.example4.

  2. 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.

  3. Make sure the AndroidManifest.xml file is correctly configured. Refer to the Requesting NFC permissions recipe in Chapter 1, Getting Started with NFC.

  4. Import the NfcHelper.java class into the project.

  5. Request for permission to administrate Bluetooth...