“Alexa written with Akka” = Aleka

As a way of demonstrating how to write code with Akka, Scala, and functional programming (FP), I started creating a new project this weekend. I named it Aleka, because it may eventually be like Amazon’s Echo/Alexa, written with Akka (and Scala).

(I suppose a better name might be “Ekko,” after Echo, but I have a niece named Aleka, so unless she objects, this works for me.)

A Perl script to delete binary files

As a quick note and a little bit of source code sharing, I wrote the following Perl script to delete all of the binary files it finds in a list of files it’s given. I named this script deleteBinaryFiles.pl, and it should be called like this:

deleteBinaryFiles.pl listOfFilesToLookAt

where listOfFilesToLookAt is a file that contains a list of filenames, with one filename per line.

Given that brief introduction, here’s the source code:

When you want to store static text in an Android file

As a note to self, when you’re writing an Android application and you think you want to store some static text in an external file, a better approach can be to create a resource file under res/values.

For example, I’m currently adding some help text to an Android app, and to do that I created a file named strings_help.xml under the res/values directory. That file contains HTML wrapped in an XML CDATA tag, like this:

How to create a method that returns a function in Scala

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 9.7, “How to create a method that returns a function in Scala.”


You want to return a function (algorithm) from a function or method.


Define a function that returns an algorithm (an anonymous function), assign that to a new function, and then call that new function.

The following code declares an anonymous function that takes a String argument and returns a String:

How to create inner classes in Scala

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 4.16, “How to create inner classes in Scala.”


You want to create a Scala class as an inner class to help keep the class out of your public API, or to otherwise encapsulate your code.


Declare one class inside another class. In the following example, a case class named Thing is declared inside of a class named PandorasBox:

An Android onTouchEvent method example (View class)

If you need to write an Android onTouchEvent method inside a View class, here’s some example source code (boilerplate/skeleton code) that shows how to implement this method, including how to use the MotionEvent in the method, and how to get the x and y location of the touch event:

Source code for an Android AsyncTask (REST client) example

I just got back into using an Android AsyncTask, and it took me a little while to re-load the concepts in my head. I used AsyncTask’s a few years ago, but haven’t used them since.

To help remember how they work, I created a little AsyncTask example project, and I’ve included all of the source code for that project here. I’ll show all of the source code for my classes and configuration files, and then explain the code at the end.

Android 5 Preferences tutorial (PreferenceScreen, PreferenceActivity, and PreferenceFragment) alvin February 13, 2015 - 10:02am

Creating a Preferences screen in Android isn’t too hard. The website rominirani.com has a very good preferences tutorial that just needs a minor update for Android 5, as a piece of the code shown there has been deprecated.

To create an Android Preferences UI, just follow these steps: