Check if Android service is currently running

Sometimes we need to know if our android service is running. I always recommend binding to the service and listening for the ServiceDisconnected. However, if we need to know if a service is running from a broadcast receiver, this is how:

private boolean isMyServiceRunning(Class<?> serviceClass) {
    ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
    for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if (serviceClass.getName().equals(service.service.getClassName())) {
            return true;
    return false;

Asynchronous Java NIO for dummies

This article explains the fundamentals of Java NIO asynchronous socket programming with a very simple server/client example. Java NIO uses multiplexing to server multiple clients from the same thread. Before NIO, a server had to open a thread for each client. At first NIO is very intimidating and a bit confusing. I hope to make this as simple as possible for your understanding.
Continue reading

Custom View to draw, rotate, erase and convert images to black and white.

This article describes how to create a reusable class that can upload images from our Gallery or take a picture, put them on a canvas and move them around the screen, resize them, erase them and convert them to black and white. This tutorial uses a class that extends View and uses onTouchEvents. This is class also takes care of the VM Budget issue of loading images from the gallery by optimizing the memory each image uses. It uses android 2.2 and above.

Continue reading

Connect to MYSQL remote server database using PHP and display ListView

This article describes how to create/access a MYSQL database in a remote server from Android using PHP and display it on a ListView. Because most online tutorials did not show the full process or all source code, I decided how to create a fully functional prototype. Currently you can see my JSON objects by going to this link: which accesses my database and extracts the information. This article uses Cpanel, php and Android API 2.1.
Continue reading

SQLite database

This article describes how to create a project using an SQLite database. Most online tutorials show how to input one value. Here I will create a database of users with three values: first name, last name and age. This is then displayed in a ListView. This article includes adding and deleting users, using a Cursor, dynamically loading data to a ListView and using an AlertDialog to input user information.
Continue reading

SSL Sockets Android and server using a certificate

This article describes how to create a secure socket from an android device to a server using a certificate. It explains how to create a key that Android can use, write a secure server socket, a client socket and send information back and forth between them.

First we can start by downloading the apk file for android and the jar file for your computer (server) along with the correct secure certificate and another certificate to test that other certificates will not work. Download link:

First I will go through the steps so you can see a working example before looking at the code.
Continue reading

A camera preview with a bounding box like Google goggles

This article describes how to draw a bounding box on top of a camera preview to capture part of the image just like Google goggles does. This article mainly involves looking at a SurfaceView for generating a camera view and a View to create a canvas and draw on top of the camera view. Also shows how to use the onTouchInterceptEvent to pass touch events to lower Views. Android 2.2 API needs to be used for this.
Continue reading