At this point, the Android has the Arduino’s Bluetooth module stored in a
BluetoothDevice object. The next objective is to form the connection between the Android and
the Arduino. This work should take place in separate thread. This is because forming a
connection can block a thread for a significant amount of time. Up until now, all of the
program’s code has been written in the main thread, or “user interface thread” (UI thread). The
UI thread should never be blocked. Therefore, create a new thread class where the connection
will form. Source 6 shows the code to accomplish this. Add it as an inner class of the main class.