Wiki Search using Android Things

Image for post
Image for post

After learning about Android Things Starter Kit, I get on next to create a simple Android Things App that access the Internet and uses the Peripehral.

It is done reuse my previous simple Wiki Search App, and link it to some Android Things Rainbow HAT peripherals for the result.

Goal of the App

I have two goals of making this APP

  1. Create an App that has connection to the internet
  2. Create an App that trigger some peripherals output

Bonus item:
Use Kotlin Code and some of its language feature for the entire project
Use Coroutine for some parallel processing of the LED Strip light display

The App Functionality

This is what the App does

  1. Key in a word in the provided EditText box, and press CHECK SEARCH COUNT
  2. It will then send the word to wikipedia API, that returns the count of the word found in wikipedia
  3. While it is performing the search, the peripheral LED strip on the Rainbow HAT will lit up and down in sequence
  4. Once the result is back, it will show the result on the screen, as well as on the 14 segment display on the Rainbow HAT

Check out the video demo below for detail.

Technicality Share

I’m not sharing on the technical side of how to connect to Wikipedia from the App, as it is clearly shared in Wiki Search App

I’m covering the code that works with Peripherals here

Include the dependencies

Other than Android Things, I’m adding the Rainbow HAT driver library as below in the build.gradle.

compileOnly ''
implementation ''

Add the permission

Permission is needed to access the peripheral. Just add it in the AndroidManifest.xml.

<uses-permission android:name=""/>

One note: If you have previously installed the App without the permission, you’ll need to uninstall the App first, then reinstall the App. Else your newly added permission take effective.

LED Strip

To access the LED Strip, you need to initialize it.

val ledStrip = RainbowHat.openLedStrip()

As there are 7 LED Strips, you’ll need to assign an array of 7 Integer.

val colors = IntArray(7)

You could put and RGB color to the array content as you wish, then write the array content to the LED Strip


Then you’ll get the color shown on the display.

14 Segment Display

To access the 14 Segment Display, you need to initialize it.

val segmentDisplay = RainbowHat.openDisplay()

After that, you’ll need to enable it


Finally you just display the value (it accept String, Integer, Double and even char).


Then you’ll get the word displayed.

Example Code

You could get the code below.

What’s more

If you like to explore beyond that, and also use the temperature sensor feature of the AndroidThings, you could check it out in

I hope you appreciate this post and it’s helpful for you.

You could check out my other interesting topics here.

Follow me on medium, Twitter or Facebook for little tips and learning on Android, Kotlin etc related topics. ~Elye~

Written by

Passionate about learning, and sharing mobile development and others

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store