Tile Troubles Pt.2, 12/100 Days of Code
Virtualization Technology is cool and all, but sometimes you need the real thing to get the job done.I successfully installed a custom Tile on an Android Virtual Device. However, it didn’t go quite as planned…
Though the Tile appeared, I had no way to test it properly. The virtual device metrics might note vibration patterns, but I needed to make sure my Tile worked in real life. Like a madman, I installed it on my phone.
It worked! Clicking the Tile made the phone vibrate. I got it to work on my first try…sort of.
Clicking the Tile again didn’t turn it off. I had to go into the Settings menu and force close the app. I turned back to my computer to examine my code and the tutorial code to see where I went wrong.
I looked up one of the methods the writer used and found it in the Kotlin API. Problem found.
I was writing in Java completely oblivious to the fact the writer of the tutorial was providing code snippets in Kotlin. In my experience, it’s important to note the resources required to follow an instruction guide from the start. Nowhere did it mention the code was written in Kotlin!
Now I had a new hurdle: locating any logical errors in my code. I code primarily in Java, so I’m not sure what the writer’s intentions were for each method written thus far. One method used a while loop to make the phone vibrate while the Tile was on, but it’s unclear whether or not this is a good practice in Java. What is clear, is that the while loop ran endlessly since my app didn’t have a way to end the loop, thus preventing me from toggling the state of the Tile. This is why I had to force close the app.
This project was helpful so far. I’ve learned a good amount about how Tiles are created. Now that I got my feet wet, I’m ready for the final boss…Toggling Mobile Data.