Application code

So far so good. At the end of previous step, we hope that you have included the earlier mentioned files in your code preferably in a separate package. Now, we start writing our App:

  1. We shall create a simple UI, which is nothing much but just a text view on a screen to display our Beacon data. For this, navigate to the activity_main.xml file in the design view and drag and drop a textView. Apply constraints and position the text view to the top of the screen:
Figure 14: Adding the TextView
  1. Our very basic UI is ready. Now, we need to scan and discover the Beacon first. For this, create a class by the name of BleUrlDeviceDiscoverer ...

Get IoT Projects with Bluetooth Low Energy now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.