• 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 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.

  • Using the file API to read a file in Android

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

  • Android SharedPreferences in Kotlin

    A preference file is the easiest and most straightforward way to store data in Android app. A preference file stores pairs of key-value items, like dictionaries or maps, and they are stored in the file system as XML files.

  • How to use Anko's doAsync for background task

    I wrote a series of post on how to handle background processing in an Android app. You don’t really need to read them before you dive into this post, but it will give you context and more background about jank and how we use Threads, Handlers and AsyncTask to avoid it. The three previous post about jank are the following.

  • Creating and looping through Kotlin Map

    It’s very easy to work with Maps in Kotlin, you can see for yourself in the following examples.

  • Creating and Looping through Kotlin arrays

    You can create an Array like using the emptyArray function, like this

  • Kotlin Collections

  • How to handle clicks and long-clicks in Kotlin

    An onClickListener for a Button View object can be coded like this

  • Rip youtube videos from the command line

    You can rip YouTube videos from the command line in Linux and OSX. There could be ways to do this in Windows via Cygwin, but I did not try that.

  • Install Samsung CLP-315 on Linux

    Get the UnifiedLinuxDriver.tar either from the CD that came with the printer or from the Samsung site. You need to navigate the site a little bit. Go to Support and Downloads page Find a way to upload UnifiedLinuxDriver.tar.gz to your headless server. FTP or SCP or even Samba shares should do it

  • Android Jank

    The following code used to trigger ANR (Android Not Responding) error

  • Android Jank

    The following code used to trigger ANR (Android Not Responding) error

  • Android Threads, Handlers and Messages

    If your app suffers from slow UI rendering, then the system is forced to skip frames and the user will perceive stuttering in your app. We call this jank. –

  • How to launch an Activity in Kotlin

    Android is made up of loosely coupled components. What if you need your components to talk to each other e.g. launch another Activity? How do you think we should manage that? If you have any experience with desktop programming, you might think that you can do it with a code like this

  • Kotlin supports variable function 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.

  • Using Google fonts in

    Using Google Fonts in

  • Learn Android Studio 3 (Java ed)

  • midweek blues

    I want it that way, Casey Abrams

  • How to write good

    The first set of rules was written by Frank L. Visco and originally published in the June 1986 issue of Writers’ digest. The second set of rules is derived from William Safire’s Rules for Writers. There’s plenty of these circulating in the interweb, usually in graphic form.

  • Android, Intents can carry data

    Android Intents can do so much more than just just simpy activate or launch another Activity in your app, it can also carry data. This capability lets you pass around data between components.

  • OkHTTP and Threads

    Android has various ways to run your code in the background. From what I can recall, we can use any of the following;

  • Kotlin Extension Functions

    In Java, if we needed to add functionality to a class, we could either add methods to the class itself or extend it by inheritance. An extension function in Kotlin allows to add behavior to an existing class, including the ones written in Java, without using inheritance. We can define additional behavior for an existing class and do the definition outside of that class.

  • Android's Snackbar in Kotlin

    The Snackbar is a view that’s mostly used to give quick feedback to the user, like Toast. It appears at the bottom of the the screen and disappears after some timeout. Sometimes the user can “swipe” the Snackbar to make it disappear. But unlike Toast, you can put some actions in the Snackbar.

  • Android onCreateOptionsMenu

    Menus can be created either by using an XML resource file or by dynamically adding menu items through program code. This post is the latter.

  • Menu on Android ToolBar, using XML

    You can create a menu for an app in 3 steps. First is to create a menu resource file which will contain all the menu items, Next steps is to inflate the menu file and attach it to a Menu object and lastly, handle the events for each menu item.

  • Toast message in Kotlin

    An Android Toast is a small message displayed on the screen, similar to a tool tip or other similar popup notification. A Toast is displayed on top of the main content of an activity, and only remains visible for a short time period; a sample Toast message is shown on figure 1.

  • cmd line arguments in Node

    When you pass arguments to Node program in a command line, they are kept in an array inside the process object. The name of the array is argv. The contents of process.argv is as follows

  • Working with Python numbers

    Python has counting numbers (ints) and measuring numbers (floats). You already know what these are, the ints are whole numbers, that’s why we use them for counting and floats are the ones with decimal parts — that’s why they are perfect for doing measurements.

  • Kotlin Intro, Setup and Hello World

    It’s the new(est) kid on the the JVM block.

  • Quick guide to using Vagrant and VirtualBox

    What is Vagrant? It’s a;

  • adb server out of date

    adb server out of date - linux

  • Vagrant setup

    You need to do 3 things. 1) Install Virtual Box and Vagrant 2) Add a Vagrant Box image and 3) Define a VM

  • Basic flashcard game in JavaScript

    The use case

  • JavaScript's Complex Types

    Two basic data stuctures you can use in JavaScript are Arrays and Objects. Unlike simple types like String, Number or Boolean, Arrays and Objects represent a collection of values, not just single or scalar values.

  • How to submit a sitemap for Google's

    Things you need to have or completed before you proceed.

  • JavaScript keywords

    JavaScript keywords are special words that you can’t use in your program as variable name, name of a function or name of a class.

  • JavaScript's code structure

    JavaScript codes may either be embedded in HTML documents or referenced from it. When they are referenced from an HTML file, they are known as external JS files. External JS files lives in a source file, they usually have an extension of .js

  • Android's Location API

    GeoLocation is a major fuctionality of a mobile device. There are plenty of practical uses for this nifty feature, apart from stamping where you were when you took that photo.

  • Using Eclipse ADT for Android

    Make sure you have already installed the Android SDK and that you have properly configured the PATHs to tools and platform-tools. Make sure also that you have properly installed and configured Apache ANT.

  • How to use Android's Logcat

    This section is not about some spiffy tool that lets put breakpoints in your IDE or something that allows you to step through your code line-by-line. Nothing like that. This is about how to use a crude and old technique of debugging. Outputting something into your screen at specific points in the code.

  • Small voice recording app in Android

    Voice capture and voice playback in Android is handled by two classes; and, for recording and playback respectively.

  • Basic sqlite programming in Android

    What we want to do;

  • How to sign an Android app

    You have to sign your app before you can sell them and before other people can install them on their devices. Follow the steps below to sign your app.

  • A basic ListView in Android

    Source files at the github page

  • Photoviewer in Android using implicit Intents

    Photo Viewer in Android using Implicit Intents This is small exercise on how to create a photo viewer app that responds to implicit Intents.

  • Cannot find build.xml

    This compilation error means the android sdk is looking for the build.xml file which is inside the folder sdk.dir/tools/ant. The compiler cannot find it, hence the error.

  • Android programming readiness checklist

    Before diving into Android programming, there are a couple of skills you might want to look at. It is possible to simply jump into programming, build some basic screens by copying example codes from the internet or from other programmers. But you cannot go to the deep end. When you find yourself neckdeep in the not-so-trivial parts of Android programming and you feel stuck, that’s probably because you haven’t covered some bases.

  • Faturitis curve

  • IT week at Asia Pacific College

    In a few hours, I will head to Asia Pacific College to give an introductory talk about Android applications development. I haven’t been to APC for a very long time, and I haven’t talked in front of a crowd for a very long time as well, much less give an introductory talk inside an auditorium—but no matter, I think all will be well.

  • Book references for Android programming

    This the short list of the books I used for my android learning. I did not list all of them, only the ones I liked and the ones I thought would actually help a beginning developer get into grips with android.

  • Android Screen shooting with ddms

    1. You need a properly installed Android SDK setup before you can proceed. Launch ddms from the command line. The path to the android executable has to be included in your PATH variable – ddms
    2. Enable USB debugging on the Android device, before you connect it to the PC (or Mac, or Linux). This is usually done by accessing Settings > Applications > Development, there is a check box beside “Enable USB debugging”. Connect the Android device to your PC via a USB cable
    3. The connected device should now be visible within the DDMS window. Select it, then
    4. Press CTRL-a on your keyboard
  • On Studying and practicing Android programming

    These tips might be useful for you if you want to get into Android programming.

  • Simple Samba File Server setup in Debian Linux

    CIFS is short for Common Internet File System, it’s also known as SMB which is short for Server Message Block.

  • Hacking docco for Java programs

    Docco is a quick-and-dirty, hundred-line-long, literate-programming-style documentation generator. It produces HTML that displays your comments alongside your code. It can be used to generate documentation for JavaScript, CoffeeScript, Python and Ruby. But it won’t work for Java source files. There are ports of this script so that it can work with other languages, including Java, some prominent projects are Jocco and Marginalia (for Clojure).

  • Use Linux CUPS printer from OSX

    Click the Apple logo at upper-left most corner of your desktop, click Print and Fax

  • Python's while loop

    Python’s while loop behaves exactly as you might expect. It works a lot like in other languages you may have used.

  • How to connect to Ubuntu from Windows using RDP

    1. Get the tsclient with the command sudo apt-get install xnest
    2. Enable xdmcp. Edit the configuration file, it’s located at etc/gdm/gdm.conf
    3. Uncomment RemoteGreeter in the daemon section. Delete the pound or sharp sign on theleft of RemoteGreeter
    4. Find the xdmcp section and change the value of Enable key, set it to true
    5. Log out of Ubuntu in order to restart the gdm. Altenatively, if you don’t want to logout, from the Terminal, you can restart with this command sudo /etc/init.d/gdm restart
    6. You can now connect from your Windows machine to an Ubuntu machine using Remote Desktop Protocol
  • Ways to View Google Tasks

    1. Via Snippage - This is not a specific application written for Google Tasks. It actually can produce an application out of any web page
    2. While in Gmail (Of course!) - but I don’t want to leave my, so, no
    3. Get a FireFox side bar, it’s an add-on
    4. In iGoogle, the GTasks is a gadget, or;
    5. You can access the Google Tasks url directly. Hmmm, this can work. I can set the url of the browser to, then set the browser full screen. I think this can really work
  • Automatic backup of MySQL database

    To create a backup of a mysql db, the command we need is the following;

  • Linux mpd and stereo receiver

    This project will let you control a music player daemon running on a Linux box. The Linux box (headphone jack) will be connected into a stereo receiver (input. It’s an over engineered music player. But if you don’t have anything better to do with an old notebook, this might save it from the junk yard.

  • php mysqli oop

    Start by connecting to the database

  • Android's BroadcastReceivers

    BroadcastReceivers are one of the four Android components (the other three are Activities, Services and ContentProviders). A BroadcastReceiver is something that waits for a specific Intent to be broadcasted, and then it acts on it.

  • PHP How to work with dates

    Your programs will deal with date and times some of the time. On some occassions, the date and time data will be inputs coming from an html view. These inputs will be in string format which means you need to transform them to the appropriate date/time format before you can persist them to the database. On other occassions, you will read the date/time data from a database and then display them in the html view.

  • Java's switch statement

    The switch statement has a slightly different structure from the if-then statement which makes it, in some cases, more readable than an if-then construct that needs to handle multiple pathways. The basic form of the switch statement is as follows

  • Connect to database via mysqli procedural

    Start by connecting to the database. PHP is a server side scripting language and heavily dependent on the http protocol. The request/response nature of http means that whatever data or information you created on previous requests, will not matter in future request. Everytime you need to do something that involves a database operation (insert, delete, update or select), you need to make a connection to the database before you can do anything else.

  • Java's if then else statement

    The if-then statement is one Java’s branching construct. You use a branching construct when you want to execute some of your statements only when some conditions are true.

subscribe via RSS