The following is the first few sections of a chapter from The Busy Coder's Guide to Android Development, plus headings for the remaining major sections, to give you an idea about the content of the chapter.


Basic Bluetooth RFCOMM

For short-range communications, Bluetooth is fairly popular. It is widespread, available on mobile devices, notebooks, and many Internet of Things platforms. It performs reasonably well, at least for moderate amounts of data. Android has a variety of classes in the Android SDK for adding Bluetooth communications to an app.

However, Bluetooth overall is a vast topic. The documentation for the Android SDK classes is spotty. And it can be fairly difficult to make sense of how all the different pieces are supposed to plug in together.

In this chapter, we will explore a sample app that demonstrates Bluetooth communications between two Android devices and use that to see how to work with Bluetooth on Android. For extra fun, we will also peek a bit at how things differ when you try to use Bluetooth on an Android Things device, such as a Raspberry Pi.

Prerequisites

This chapter makes use of RxJava, foreground services, RecyclerView, and data binding.

If you want to run the sample app, you will need two Android 5.0+ devices, each with working Bluetooth.

A Quick Bit of Scope

The preview of this section was lost due to a rupture in the space-time continuum.

About the Sample App

The preview of this section was traded for a bag of magic beans.

Bluetooth and Permissions

The preview of this section is off trying to sweet-talk the Khaleesi into providing us with a dragon.

The Rx for Your Bluetooth

The preview of this section was lost in the sofa cushions.

I Can Haz Bluetooth?

The preview of this section was fed to a gremlin, after midnight.

I Feel a Bond Between Us

The preview of this section was whisked away by a shark-infested tornado.

A Voyage of Discovery

The preview of this section is presently indisposed.

Serving and Shouting

The preview of this section was accidentally identified as an Android 'tasty treat' by the Cookie Monster.

Reach Out and Touch Someone

The preview of this section is out seeking fame and fortune as the Dread Pirate Roberts.

Ping and Pong

The preview of this section is in an invisible, microscopic font.

Differences with Android Things

The preview of this section was fed to a gremlin, after midnight.