Skip to content
Coding Fanatic
  • Android Development
  • News and Reviews
  • Road2Pro
  • Tutorials
  • Services
  • About

Tile Troubles, 11/100 Days of Code

  • December 4, 2018December 5, 2018
  • by Richard Clarke

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

Related

Not This Exit Again! 10/100 Days of Code
Tile Troubles Pt.2, 12/100 Days of Code
Richard Clarke
Richard is currently a developer using Java and Android Studio to build custom applications for Android. Richard tutored in mathematics at Montgomery College, and worked in Information Technology before entering the Software Development industry as a Quality Engineer.
Android development Java Mobile Tiles

Related articles

Your New Favorite Stopwatch App!…
Two for Two BABY! 7…
…But the App is for…
Play Store Blues – 5…
Top 4 Tips for Android…
No Dice – 3 of…

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Join the mailing list!

This field is required.

Check your inbox or spam folder to confirm your subscription.

Follow me on social media!

  • GitHub
  • YouTube
  • X
  • Instagram
  • LinkedIn
My Tweets

Join the mailing list!

This field is required.

Check your inbox or spam folder to confirm your subscription.

Follow me on social media!

  • X
  • GitHub
  • LinkedIn
  • YouTube

Archives

Theme by Colorlib Powered by WordPress