I'm Ted Hagos. I've been coding for the better part of the last 3 decades, a code instructor for half of that, and an author for a third of that.

Recent posts

  • Programming Resources


  • How to Handle Clicks in Android

    To follow the tutorial, you’ll need to create a project or download the project file here. I created this project using Android Studio 4 (Canary version, at the time of writing). Below are the project details;


  • Android Studio Time Savers

    What we usually mean when talking about productivity is that we want to do what we need to do in the shortest possible time; that means keyboard shortcuts, templates, snippets etc. In this section, we’ll take a peek at some of what Android Studio has to offer give our productivity a little boost. We won’t go into detail; that’s not the goal, but rather just to show you what’s available in Android Studio.


  • Basic Android APIs for the Game Programmer

    This is a sample text


  • How to pass command line arguments to a Node app

    You can pass an argument to a Node app like this


  • Event Handling in Android

    The user interacts with an app by touching, clicking, swiping or typing something. The Android framework captures, stores, processes and sends these actions to the app as event objects. The diagram (figure 1) below summarizes these interactions


  • How to create a simple Random number generator in Java

    If you need to generate Random numbers in your Android app (assuming you’re using Java), you can simply use the java.util.Random class.


  • How to open a file in Kotlin

    Just like in Java, you use the java.io classes, like this;


  • Kotlin's function can take variable arguments

    Functions in Kotlin, like in Java, can also accept an arbitrary number of arguments. The syntax is a bit different from Java, instead of using three dots after the type ... , we use the vararg keyword instead.


  • Reified Generics in Kotlin

    Let’s deal with the meaning of reify first. It means to make something real, and the reason we’re using reify and generics on the same statement is because of Java’s type erasure.


  • Variance in Kotlin Generics

    We’ll need to review some of our OOP basics to prepare us for a discussion on variance. Hopefully, we can jog your memory and remember some of the fundamental principles of object-oriented programming.


  • Kotlin when, switch statement on steroids

    Kotlin doesn’t have a switch statement, but it has the when construct. It looks a lot like the switch but it packs a lot more punch. In its simplest form, it can be implemented like this


  • Kotlin if-then expressions

    The if construct in Kotlin works almost the same as in Java.


  • Kotlin while loops

    Kotlin has a while loop that looks and behaves exactly like the one in Java


  • Kotlin Exception Handling

    Kotlin’s approach to exception is similar to Java. Somewhat. It uses the try-catch-finally, just like in Java. So, your knowledge about how try-catch works commutes nicely to Kotlin. The code below should be very familiar. It shows a typical code on how to open a file


  • An introduction to Kotlin functions

    Kotlin functions are defined using fun keyword, followed by the name of the function, a pair of parentheses, optional parameters, the return type of function and then the body of the function, which is pair of curly braces. It’s pretty much like a Java function, except that in Java, we have no fun (pun intended) and the type of the function is written to the left of the function (in Java), while in Kotlin, the return type of the function is to the right of function name.


  • 100 days ML challenge - day I

    Like most challenges that I took, I know that I won’t be able to do this challenge consistently everyday. But here goes the #100dayMLchallenge. This is my day 1.


  • Using the File API to write a file in Android

    The following snippet shows how to write a file in the internal storage (standard location, not cache).


  • Android architecture

    The most visible part of Android, at least for developers, is its operating system (OS). An OS is a complex thing but for the most part, it is what stands between a user and the hardware. That is an oversimplification, but it will suffice for our purposes. By “user”, I don’t literally mean an end user or a person. What I mean by it is an application, a piece of code that a programmer creates, like a word processor or an email client.


  • Android AsyncTask

    In previous posts (Android Jank and Android Threads, Handlers and Messages) we explored ways on how to run code in the background. Why would we want to do that? So that UI Thread is freed up to do UI stuff like creating and updating views. Coz if we burden the UI Thread with other stuff that doesn’t concern the UI, like doing I/O work or doing complex calculations, the Android runtime will reduce the framerate of our app which will cause it behave sluggishly — in short, jank.


subscribe via RSS