Tile Troubles, 11/100 Days of Code
Having an Android phone means programmers can fix bugs left behind by manufacturers.
I’ve been working on a fix for my mother’s phone. Sometimes she uses up her data plan by accident when she forgets to turn on WiFi at home. To remedy this, I showed her how to toggle Data and WiFi using the buttons in the notification area of her phone. As it turned out, there wasn’t an option for toggling mobile data.
Not a problem. On phones past I installed Quick Settings apps that provided these buttons in the notification area. However, I was shocked to see there weren’t any new Quick Settings apps that gave her the option to toggle mobile data. I did some research and found that phones running Android 7.0, Nougat, could customize the Quick Settings area using Tiles.
Tiles and TileServices are classes in Android used for displaying and interacting with the small button-like options found in the Quick Settings area of the notification drawer. Tiles hold the state of the Tile displayed (on or off) while the TileService provides a Tile that can be added. To get an idea of how this works, I followed a tutorial for a simple Tile that would make the phone vibrate when turned on and stop when turned off.
I imported both classes in the MainActivity.java file and overrode all the methods of the TileService class, but I couldn’t get it to work.
Every time I tried to run the app, I got an error message saying “Default Activity not found”. As it turns out, I was supposed to create an additional java file for the service, not replace the MainActivity java file.
I made a new Java file for the service and left the main activity file empty. I edited the Android manifest file to reflect my changes and include the new service.
When I started up the virtual device, sure enough, the tile appeared! Unfortunately, things didn’t go quite as planned…
-CF