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 is en route to Mars.

Bluetooth and Permissions

The preview of this section is en route to Mars.

The Rx for Your Bluetooth

The preview of this section was the victim of a MITM ('Martian in the middle') attack.

I Can Haz Bluetooth?

The preview of this section is sleeping in.

I Feel a Bond Between Us

The preview of this section did not survive Thanos's finger snap.

A Voyage of Discovery

The preview of this section is sleeping in.

Serving and Shouting

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

Reach Out and Touch Someone

The preview of this section is being chased by zombies.

Ping and Pong

The preview of this section will not appear here for a while, due to a time machine mishap.

Differences with Android Things

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