Flying toasters on an Android

E has been friends with M since they were little kids. One of their fond memories involves selecting and watching the After Dark screensavers on their teacher’s computer in elementary school.

For Christmas this year, E decided she wanted to figure out a way to give M the gift of After Dark for her phone, so she could pick and watch a screensaver any time she wanted to. Since I’m a computer scientist, I assured her we could pull this off.

android-toasters

I haven’t made many Android apps before, and I don’t own an Android phone, so getting the development/emulation environment set up was actually one of the biggest hurdles. I had set it up on my iMac over the summer for a course I took on the software development process, but ran into some emulator issues and conflicts with Android SDK versions. I spent way too long trying to fix that before I finally decided to wipe everything and start fresh.

I ended up going with Android Studio for Mac and Genymotion. Genymotion allows for much faster, smooth emulation, more along the lines of what I’d come to expect with iPhone development/emulation. It’s a little weird to set up, but I got it after starting clean.

So then came the issue of how to do the app. I briefly considered looking at wrapping up DosBox and the original After Dark screensavers, but decided that might be a bit overkill. What seemed like a better compromise was to get videos of each of the screensavers, and build an app that simply played the videos. Not quite a true screensaver, but it would at least let the “customer” get what she wanted, which was to watch the screensavers.

After the environment was set up, I had the privilege of haggling with codecs. Android wouldn’t play the H.264 files that Handbrake created from my source videos, so I had to resort to MPEG-4 (FFMPEG) compression, which led to worse-looking, larger files. But it could at least play those!

As far as programming goes, I set up a custom player view that filled the screen with the video window and didn’t offer any player controls. Real screensavers couldn’t be paused or rewound, after all!

When the app opens, an activity is presented with a list of the screensavers, and each button plays a different screensaver. The Android system back button is used to back out of the screensavers.

The last hurdle was getting the app on M’s phone. Not having a real phone to test things on, I was forced to wait until we could borrow her phone for a little bit to try loading it. And it wasn’t until I tried loading the app that I learned that Android handsets will not run unsigned code!

Luckily, Android Studio has a wizard to help with this process. It’s under Build > Generate Signed APK, and it guides you through the whole process. I was able to transfer the APK to the phone using Android File Transfer, open the APK, and install it after enabling developer mode on the phone.

M was very delighted by the flying toaster icon on her app screen, and even more so by the flying toilets and the bad dog that terrorized her phone.

The source code (minus the videos of the flying toasters – they were just too large!) is available here:
https://github.com/jamesmallen/afterdark2

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.