Featured Posts

<< >>

File Manager


This app is my response to a number of overcomplicated file managers in Google Play that are often outdated and disregard new APIs and design guidelines. I created this app with simplicity of use and convenience in mind. It allows users to add bookmarks to slide-out drawer, and it comes with preset bookmarks to default

Convoy Trucking Android app


Convoy Trucking android app a companion app meant for Convoy Trucking players to view website content without having to switch to web browser. It is designed for both phones and tablets, and looks beautiful on both.

It fetches data as a json feed from Convoy Trucking API and uses Universal Image Loader library to download and cache images.

The app can be downloaded from Google Play: Convoy Trucking.
The source code is available on GitHub.

2013-07-28 13.14.39_framed 2013-07-29 17.54.22_framed 2013-07-28 13.13.58_framed

Dubline Storymap


Dubline Storymap is a customized version of Storymap with its own stories talking about Dublin city’s attractions. Just like the original Storymap, Dubline offers its users rambles across town as well as creating custom ramble by user which highlights nearest stories on the map.

Dubline can be downloaded for free from Google Play: Dubline Storymap

2013-07-24 19.24.42_framed2013-07-24 19.24.21_framede8b15271-3758-4bcd-afe8-b6dc5ada378b

MySQL Backup Engine

Finally, I got around to updating my database backup utility! I started by creating a MySQL connection library and a “Backup Engine” library, which I hooked up to a test console app. This approach will allow me to have two different applications that use the same back end. One application will be a windows client and the there will be a command line utility as well.

The original version was created over a year ago and hasn’t been worked on until now.

The new project consists of:

  • Database connection library
  • Database Backup engine
  • Commandline app
  • Windows forms app

It saves backup into .sql files of predefined size. I created a DynamicFile class which saves text data into multiple files and allows the programmer to get the list of filenames afterwards:

Actually, I extended this class into DynamicSqlFile and created some methods useful for writing SQL files:

It has a handful of useful methods, like WriteComment(), which automatically appends “– ” before the text and ends it with a NewLine character. It also returns and instance of itself, making this possible:

Which makes for very compact and readable code. It ends up looking like this in the SQL file:

Commandline interface:


Work in progress

Work in progress

Edit distance algorithm

This little algorithm is one of the coolest things I learned from the programming lectures with Dr Bryan Duggan. Essentially this algorithm shows how much one word needs to be edited to change into another word. It is very useful for writing a spellchecker, or a music recognition app. Below is a C# implementation of the algorithm:

the getEditDistance() method returns 0 if both words are equal, 1 of one letter needs to be changed, etc.

Notification buttons

Notification buttons

This tutorial shows how to make an audio playback service and how to control audio playback using buttons on a notification. I am going to assume that you have some knowledge of android app development, and know your way around Eclipse, or other SDK used for Android. This is my first tutorial, so please let me know in comments if anything needs to be explained in more depth, or point out any mistakes made.

1. Create service

First things first, we need to create the service that will play music. You can do that by creating a new class that extends Service. You will also need an instance of MediaPlayer. Your service should also implement OnPreparedListener and OnCompletionListener interfaces to receive callbacks from the MediaPlayer. Your code should look similar to this:

onCreate() is called when your service is first started. We’ll use it to instantiate the MediaPlayer, and set listeners. onStartCommand() is called every time you launch your service from an activity – this could happen several times during service’s lifetime. Returning START_STICKY causes your service to stay alive after onStartCommand() finished executing.
You should also define your service in your project’s manifest. Put the following between the <application> tags:

2. Let’s play some music

Now that we have the service, let’s make it play the music. We will modify onStartCommand() to handle the incoming intent, and override onDestroy() to stop the music when service is stopped:

This will get the url from intent and use it as a data source for media player. You can use this to stream media from the internet. the prepareAsync() method starts buffering the audio stream in a secondary thread, and will call onPrepared() when finished – that’s where you start playback by calling start() on the MediaPlayer.

If you want to stream music from the internet, don’t forget to request the INTERNET permission inside the <manifest> tags of your manifest:

Next we’ll create an Activity (you should know how to do this) that will start the service. Add 2 buttons the layout: first button will start the service and play music, while the other one will stop the service:

The code above will start the service with url link provided. It should start streaming Radio Nova. The app should work at this stage. Go on and try it!

3. Show the notification

The final part of this tutorial is creating the notification that will show when service is running and present user with playback control buttons. Let’s create a showNotification() method inside our Service. The notification will have Stop and Pause Buttons. You can add buttons by addAction(). We should also define the broadcasts for those buttons.

We will use NotificationCompat class from the support library for building the notification so it’s backwards compatible. If you want you can use the Notification class, however it’s not recommended.

To make my life easier, I made the createPendingIntent() method to create broadcast pending intents easy:

startForeground() method will bring your service to the foreground by showing the notification.

Notification should be shown whenever new stream is played:

Now all that’s left is handling the button presses. To do that, we need to create a BroadcastReceiver, register it inside onCreate() method, and unregister when service is destroyed:

At last, we should implement the onCompletion() method. It is called when song finished playing. In my implementation it simply stops the service:

That’s it! You can now test the app. When you start the audio, you should be able to see this in your notification shade:

Notification buttons

Of course, the app is a bit rough around the edges; the “pause” button doesn’t turn into “play” when you press it, but I will leave this as an exercise for the reader.

Full source code: