The Accidental Hero

The Accidental Hero

I was having a late lunch, as usual. There are several reasons for that, first, it seems everyone in Addis Ababa have lunch at the same time, so the restaurants are always packed to the brim. The second reason is because, you can eat a 30 mins lunch, but it can take you 1 hour to commute to and fro. Plus another 30 mins waiting for your lunch. So I normally eat my lunch late.

This day, I was driving to a restaurant about 10 mins by road from my office, I usually use these driving times to think about the project we are deploying for the client in Addis Ababa. They are fine with the functionalities and the User Interface, but they are really hagging us about the overall user experience, so these 10 to 15 mins drive are usually think sessions for me.

There was a taxi in front of me, who was driving very slow, barely about 30 KPH, I didn’t mind, so I was just slowly driving behind him, thinking. The driver behind me wasn’t that patient, he was hooting as loud as possible. When I got the chance, I pulled a bit to the side and he passed, but the taxi driver wasn’t that considerate. The car was a Toyota Vito, and he was pushing his horn as loud as possible. It was comical at first, but then it became annoying, and after a while, I gave up my thinking session, concentrating on the drama going on in front of me.

What I am going to describe next is my opinion of what actually happened. The Vito got a chance, probably because it was a small car, he floored the accelerator and he started overtaking the taxi. Halfway through, when he was side by side with the taxi, he slowed down and started saying something to the taxi driver in Amaric. The taxi driver didn’t keep quiet either, this exchange of words went on for about 30 seconds; then I saw it. Both drivers couldn’t see it because they weren’t concentrating on the road. The was a stationary lorry on the road, right in front of the Vito.

What happened next was pure magic. If the Vito had not accelerated more than the 25 KPH it was going, it would have been fine. But the Vito driver decided he’s had enough and floored the pedal again. Just seconds before reaching the lorry. All the while I had my hand on my horn, at the same time flashing my light, trying to get the attention of the angry drivers, but it didn’t work. The Vito driver floored the acceleration, his eyes still on the taxi driver and in a split second there was a big bang, a big noise, metals flying everywhere, the taxi driver braked. I braked, people scrambling everywhere and it was all chaos for a moment. The Vito had ran straight into the lorry. And then silence.

Then I started hearing a faint hooting from the distance. The hooting started growing louder and louder and louder until I realise it was from me. I still had my hands on my horn. I removed my hand and then once again silence. I looked at the taxi driver, he was gripping his steering as if his whole life depended on it. His mouth wide open. I looked back at the Vito, now barely recognisable. I saw a faint smoke coming from the car, and something moved at the passenger seat.

Then it hit me, if there’s smoke, then there’s fire, or there will be fire. The driver was still in the car, and that something or someone beside him in the passenger seat. I couldn’t remember him having a passenger. I started pushing my horn again. This time the taxi driver was jolted back to life, he moved his taxi. I drove a bit away from the accident scene, parked my car, took off my shoes and my jacket and in a split second I was running bare footed with only my socks on towards the scene of the accident.

At first people were trying to rescue the Vito driver, but by the time I got back to the scene, the smoke from the car was beginning to get thick and people started moving back in case there was an explosion (or so I thought).

I tried the driver door, but it wouldn’t budge. I knocked on the window and the driver moved. Good. This time, my brain must have been in overdrive. I took off my shirt, rolled up my jeans and climbed into the lorry, looking for something, anything to open the doors with. I found something like a wrench, but it was heavy enough. I climbed back down quickly. This time the smoke has filled the car, so I couldn’t see properly. I smashed the rear windscreen several times with the wrench like tool, and finally it gave way. Hot smoke blew in my face and for a moment I was stunned. I quickly regained my composure and I found that smoke was clearing from the car.

At that point, I was afraid to go into the car. But then I remembered I have a fire extinguisher in the car. I ran back to the car, found the doors ajar and wondered if I lock them or not. My brain told me I couldn’t care about that now. I took my fire extinguisher and ran back to the scene. I unhooked the fire extinguisher, and tried it to see if it works, it did. I placed the extinguisher at a safe distance, hoping that if a fire started while I am inside, someone wil be brave enough to use it. I climbed into the car, and found that the thing that moved was a Dog. I later learnt that the driver was rushing the Dog to the veterinary. I looked at the driver, he has his seat belt on, and the air bag didn’t deploy. I tried the door from the inside, it gave way a little. I gingerly took the Dog and place it on the back seat. I didn’t know how injured it was, but it was in a bad shape. I sat on the passenger seat and started kicking the driver door as had as I could. My feet was hurting because I was barefooted, but I didn’t care.

Two of the braver onlookers must have summoned up enough courage. The came to the car and started pulling the door while i kicked. It helped. The door came off. One of them unhooked the seat belt and two of them carried the driver out. I took the Dog and came out.

They were speaking Amaric, so I started shouting “Who Speaks English”, “Who Speaks English”, one of them came to me and I told him, tell them to take him to my car. He told them and they did. We place the man on the back seat. He was bleeding, but we don’t know from where, I placed the Dog on the floor behind the driver seat and then I couldn’t find my car keys.

By now I was getting physically tired, but I ran back to the scene, one of the guys was putting out a small fire from the engines with my extinguisher, i looked in the car, no keys, I looked on the ground no keys. I quickly climbed back into the lorry and I found the key on the floor. At that point, I heard a very familiar but sooting sound, the sirens. The emergency services are on their way. Apparently someone had called them.

I didn’t know how far they are, so I went to the car, started the engine, and told the guy that could speak to climb in the passenger seat. I told him to direct me towards the sound of the siren. I must have been driving like mad, Or so the guy told me later (His name is Yohannes). We met the sirens after about 2 mins of driving. I waved them down, they slowed down and the guy spoke amaric to them. They stopped, took the man from the back seat, put him on a stretcher, put him in the back of their bus and started driving off. Instinctively, I drove after them.

When we got to the hospital, they didn’t allow me in, two policemen came to me and started asking me questions. I was too tired to speak. I looked at myself, the blood on me, on my backseat and all I could say to them was, will he be ok? They told me, he will be ok, thanks to me, they told me their was a big fire now at the scene and the fire service are on their way there. They said they would like me to come with them, they want to take my statement etc etc etc. I just sat there, thought about the whole incidence and tears started streaming down my face. I cried like that for about 5 mins before I got in the police car and they drove me to their station.

It’s now been a week, I am still in shock. The police men recommended I should see a therapist, but I know I will be fine. I still couldn’t bring myself to drive past the scene though. I later learnt from Yohannes that the man is OK, but his Dog didn’t make it. I am planning to visit him at the hospital before he gets discharged.


DISCLAIMER: This story is purely fictional. Thanks for reading this far.


Comments (1)

My Mac Crashed

That is something I have never have to say in my 10 years or so of using a mac. I used my first macbook for about 4 years before giving it away to a friend (who still uses it), and my current Macbook is also 4 years old….before it crashed for the first and hopefully the last time.

My friend came back from Kenya on Sunday night, and because he bought so many things, he forgot one of his bags in the Taxi….the said bag contains his Laptop. Try as we may, we couldn’t find the Taxi driver. Luckily for him, it was a new laptop, all his important work are done directly on dropbox and he still has his old laptop (unformatted).

On Monday morning, I opened my Mac, and instead of being greater by the login screen, I was greeted by a black screen. I reckoned the battery must have run out, so I pushed the power button, I saw the white screen, waited a while but no login screen…2 mins turn to 5 mins which turn to 10 mins. I was beginning to worry.
A week earlier, I had travelled to Addis Ababa, leaving my backup disk at home in Lagos, so you can understand my panic. I had backed up before leaving Lagos, but my Addis trip will not be over until another 2 weeks. I booted up again, holding the option key and I was greeted by the recovery screen. At least all is not lost.
I immediately opened terminal to see that all my files are in place, yes they are. Only problem is my mac is 250GB, I don’t have a 250GB HDD (The one I have is 100GB) nor the time to back up the mac and re-install even if I got a 250GB USD Drive. So I did the most sane thing I could think of, launched Disk utility from the recovery screen and did a repair a couple of times. I rebooted my Mac, but all I still see is the white screen….I waited another 10 mins, but I wasn’t greeted with the login screen.
I decided to re-install the Mac at that point, I thought to myself if I have done any worthwhile work in the past one week….just a bunch of documents (which are in dropbox), a bunch of notes (which are in evernote) and some code (which are in github). I decided to format the Mac and do a re-install from the recovery screen. Easier said than done.
First, The re-install download is 5GB, There’s no where in Addis I could download that….Even at the fasted internet connection I could find, it will still take about 11 hours. I tried and tried and tried several offices of my friends, but the fastest internet will take about 8 hours to complete. I finally decided to leave it overnight in a friend’s office, only to come back the next day and found out that the internet connection had gone off sometimes in the middle of the night, I have to restart installation. 
By now it is Wednesday and I have not been able to do any constructive work for 2 days. I deceived I am going to give it one more try and if it fails. I’ll pickup the Mac and wait till I get back to Nigeria. By Thursday evening, I had packed up my Mac. I could have downloaded the Mac Install from torrent, but torrent (and a lot of other things) have been blocked in ALL the places I tried.
The two weeks without my Mac was like living in the stone age. I did everything on my phone, Skype, Evernote, Documents, Excel sheets etc etc. I have an iPad back home, but I decided not to bring it to Addis, I also have two windows PCs that I rarely used…back in Lagos. This time I was wishing I had brought at least one of the iPad or the windows PC. So many things suffered, I couldn’t update my website as regularly as I used to, I have to stay plugged in to a PC or power outlet all day, because my phone battery doesn’t last more than a few hours, I have to sacrifice twitter (which is my major source of news and updates), etc etc.
Back in Lagos, I downloaded the Installer from torrent, created an 8GB Partition in my 100GB HDD I usually carry around and make it bootable into OSX. It took me about 3 hours to torrent, make the bootable disk and get my Mac back up (Maybe one day I will have enough time to post a tutorial how I did it….google is your friend though). I am typing this from my Mac.
  1. When travelling, NEVER rely on a single Computer, always pack a spare.
  2. If you are using a Mac, carry an 8GB flash disk containing bootable OS X with you.
  3. ALWAYS have some sort of Backup locally…As for me, I have a 2TB disk that I use for TimeMachine backup. It was easy to get back on track, after re-installing, there’s a point in the configuration that asks you if you want to restore from a TimeMachine backup.
  4. Use Evernote, iCloud, Dropbox, github etc…use them often…they could save your life one day.

Leave a Comment


I’m not watching my language, if you’re a kid get lost
it’s time to bear it all
say something you might get attacked for
but without something to die for, what are you living for
every day we crawl on all fours
begging to get what’s for us all
we live in a metaphor
we’ve got thieves leading whores
idiots calling the shots
we celebrate flops
we’ve got no words in us
we all a bunch of cowards
there’s no place for martyrdom
only a tiny room with a metal door

how many more will die
or be afraid to fly
our youths idling by
cos jobs are a mirage
and thousands can’t even get by
the whores get bribes
the thieves take more than they can carry
the idiots fight and die
for a loaf of bread or a plate of gravy
the innocent? cops cop
the hospitals? no drugs
education? nothing to be taught

There’s no change, except in the thieves pockets
whores sell the future of their children
putting flops at the helm
Illiterate children become idiots causing mayhem
is there a way out? maybe death

No. That’s what we must say. No
We’ve had enough, now we know
what are we? a child, yet 50 years old
We’ve been a fool for too long, it’s time to grow
So we say No.
No, thieves can no longer be allowed to steal
No, we are not going to whore our future for a piece of meal
No, we are going to fight, but you have to lead the team

Leave a Comment

From Zero To Profit – The NaLyrics Story.

Let me start by saying that I am programmer. What I am about to share with you is lessons learnt by running a business for one year. A programmer can also run a business if he put half as much energy into running the business that he put into coding.

NaLyrics is a platform for distributing and promoting songs via lyrics. It is run by myself and two other people (Not programmers). We have built a mobile app, website and wap site (mobile web). We have some unique idea on how to distribute and promote songs and we believe it will work. Our major concern is if one of our bigger competitors get a whiff of our idea, we are basically dead in the waters. So how did we manage to operate under the radar and yet go from zero to start making profit?

Let me also say that we didn’t have funding from anywhere (well, more like we didn’t want funding). First the reason why we didn’t want funding is because we are afraid the sudden fame that comes with funding might actually be the death of us. If we display our trump card too soon, they (competitors) have the money and resources to just swallow us up.

We also didn’t make any money in the first 9 months. So how did we survive? We had an initial funding of about 300, 000 naira. What we did was maximize the use of that money. For example we didn’t spend money advertising. We also found a way to run the business without borrowing. The lessons I am about to share might not work exactly for your startup, but what I learnt is if you spend time thinking about it properly, you will find a way.

We needed to advertise, without advertisement this project won’t get anywhere, like someone said, having a product without advertising is like winking in the dark. You know what you are doing but no one else does. The problem with advertisement is that it costs money and it puts you kind of in the spotlight. If we start advertising, competitors will notice us and we might be gone the next day. So what did we do? Our major market are the blackberry users, Blackberry smartphones are still the most used in Nigeria, so it makes sense to target the blackberry users. I personally scouted the web until I found two facebook groups where Nigerians post their BBM pins. The idea is to invite the people via their pins and tell them about the app. A major challenge is blackberry BBM doesn’t allow for bulk invitation. I quickly wrote a blackberry app that can do bulk invitation.

Another decision we made that paid off was, we didn’t send BBM broadcasts, because some people find it annoying. So after adding someone new to BBM, we chat with them one on one, telling them about our platform and how they can get use it. The one on one chat paid off. We have made a beautiful app and so even those that don’t like music, after downloading the app recommends it to their friends. This way we are doing advertising without being noticed by the big shots who can swallow us up.

We faced some challenges when we started. The main one is where do we get lyrics of Nigerian songs. There are a couple of websites that post lyrics of Nigerian songs, but about 80% of those lyrics are from less-known artists. Our aim is to post the lyrics of the big shots, and our major challenge is, will they give us the lyrics? Of course the answer is NO! I can remember I was able to setup a meeting with just two known artists during the early days, Vector and Mode 9. I met Mode 9 at an event and I quickly used the opportunity to tell me about my cool new app. Of course he was happy to lend any help he could. At the time he has licensed his lyrics to some other site. But after some cajoling, the site allowed us to use the lyrics on our platform as ling as we give them credit. The lessons I learnt here is, if you wait until all the conditions are right (for us, we need the artists to send us their lyrics), you might never get anything done. We need to find a way around this.

First we made the app a wiki, meaning you can register and post lyrics on the app. But after a lot of spamming, we disabled the wiki feature. We got someone who can listen to songs and write the lyrics. After posting the lyrics, we have an automated system that tweets and post the lyrics on facebook, 4 times a day for 7 days. In the posts and tweets, we copy the artist and other people related to the song, like the producer, record label etc. This gave us credibility with the artist because in a way we are helping to promote their songs via lyrics. After a while we can now count a couple artists who sent us the lyrics of their songs.

We also made some mistakes. One of them I believe now is starting with a mobile app only. We should have launched both the mobile app and the mobile web the same time. We are making some money from adverts on the app, but it is not comparable to the money we are making from the mobile web site. The mobile web site now generates about 90% of all our income and it is growing on a daily basis. If we had started with the mobile web, we would have broken even a long time ago. The lesson here is, Nigerians seldom click ads in mobile apps, but they will gladly click same ads on a web or wap site. The second mistake is we launched with blackberry app. It makes sense at the time. Our major market is Nigeria, and most Nigerians don’t use anything except blackberries and j2me devices. We had over 300K downloads from RIM appstore and another 100K from (for J2ME devices) and almost zero income from ads. Those two platforms (Blackberry and J2ME) are the most difficult to monetize.

We also learnt that analytics is good. We found out that we are getting loads of downloads from Cameroon. We couldn’t spend the needed money to translate the app. Remember we are making almost zero income. So I got a Cameroonian friend who assisted us in translating the app to French. We now have the app in two languages. Also we have to launch the Android app (It makes sense, android is becoming very popular).

To make sure we don’t run into debt, we decided to spend the 300K initial funding we had very wisely.

1. We can not get salaries
2. We can not afford to spend more that 20, 000 naira per month (this will keep us running for about 15 months).
3. We refused all forms of grants and investment opportunities less that a certain amount of money. (Sorry I won’t disclose). Because the amount we are asking for is huge, no one invested. I think it did us good, because if we have gotten the grant or small investments, maybe we would have ended up like Tiketmobile (No offence please). Although we didn’t have the opportunity to turn down 25K, but I am sure we would not have turned it down. The reason is that if an investor think there’s a market in what we are doing, we better accept his offer, especially if it is 25K and loads of experience, else he will just take his money, influence and experience elsewhere.

About a month after we launched the mobile site, we started getting some trickles from advertisements and we added two more people to our lyrics writers. Today, about a year after, we have 5 people writing lyrics of Nigerian songs, 1 person writing Gospel lyrics, 3 people writing lyrics of Ghanian songs, 2 managers (one per country) and we are in the advanced stage of starting South African Lyrics.

So in conclusion, our most important decision is to have a wap site for those who couldn’t use the app for any reason. The wap site adverts picked up faster than the mobile apps and today, we have expanded to 2 other african countries, the third one in progress, funded exclusively from the money made from the ads on the wap site.

I believe Nigeria is a big market and soon, apps will start to do well, but for startups, my advice is to build a web/wap site. If you think you have a chance of winning 25K in google app challenge, then please do build a app (case study? AfriNolly), else focus your energy on the web/wap. Then build an app. Also build an app for Android and iOS, they are the easiest to monetize in terms of Ads. Studies have also shown that iOS users tend to even pay for stuff (in app purchases) more than Android users and finally, Blackberry might be dying a slow death in the west, it is still very popular around here, build an app for Blackberry, you might not be able to monetize it, but it will give you the necessary stats you need to pitch if you need to.


Website –
Mobile – (auto detect mobile sites)
Blackberry –
Android –

Comments (2)

My First Taste Of Success

I have written a lot of code. I have worked for several companies and written loads of code for them, but most times I am not even permitted to disclose what I was working on. I have a few projects that has seen some few interests, in sourceforge and on github, personal open source projects, but not at a scale I would really call successful.

I have also written a few web apps (,, statusforsale, gridtext, jaara, webatter). Of all these I still support only the first two, the remaining I have either discontinued or have not put any work into them for over a year.

I have also written a few mobile apps, blackberry and j2me (expensetracker, faffies, king solomon’s mines, RimSMS etc). None of those ever see light of day, in terms of downloads. The only one I still support is expensetracker and I have not added any new feature in over a year.

For android, I have written a few also (ICE, JungleEscape, ChatRevolver). I never get to finish JungleEscape. But both ICE and ChatRevolver are still kind of active. Even at that, both combined did not even crossed the 100 downloads mark.

But my luck is about to turn. I have an app that has 35, 000 downloads in 4 months. Yes you read that right. And unlike faffies and the others, I have not paid a dime in advertisement!! How I did it??

First, my experience has shown me that Nigeria has a very high Blackberry user base, so I should put more effort in making the blackberry app if I am going to sell in the Nigerian market. So I made an app with local contents and put it on the blackberry app store. The first few weeks was boring, trickle of downloads per day, even zero on some days.

Next, I created a twitter account for the app. So that I can tweet @ the people I post their contents and hopefully I will get a retweet. Some of them have hundreds of thousands of followers.

Getting contents is hard, so I have foot soldiers. I pay them a token to help get the contents. At first I have 4 of them, but as we have loads and loads of contents, I let three of them go and I have only 1 for now.

Next I tried to forge a partnership with some of the content owners. So that they can retweet me and instead of me getting the contents myself, they can give me the contents themselves, before it gets to the public.

Next, I started attending events where I know my content providers will also be. It afford me time to meet so many of them and show them my app. I know it is something that has not been done before and immediately I show some of them, they were endeared to it.

By this time, we are 1 month since release and I have about 1K downloads already, that number is huge for me, and I celebrated it big. I even rewarded some of the people that downloaded with free airtime (I get some airtime for free every month in my workplace).

One day, I stumbled upon two facebook groups where people share their blackberry pins. I decided to get a new blackberry for the app, and use it to invite the people on that group and chat with them one on one, telling them about the app. I also send broadcasts once in a while. This is where things began to get interesting.

At first I sit by my computer and invite the people from that group one after the other. it was slow work and painful as hell. There’s no way to bulk invite people to your blackberry messenger. The only alternative is write a code that can do it. In under an hour, I wrote another BB app, I call it Invitator. It’s simple, give it a comma separated list of bb pins and it will send them an invite using your bb pin.

The next job is sit down and harvest the pins. It was easier than I thought and after a few days I have harvested over 1K pins. I chat with each and every one that accept the invite. It was a painstakingly boring job for a programmer. But I did it anyway. Within a month after I started this exercise, we had another 5K downloads.

All these while, I have not advertised on facebook or yahoo or google like I would have normally done. A lot of people even advised I do it, but I was head strong. I wanted to see what I can do without adverts. Because of the increase in downloads, reviews and comments and RFEs starting pouring in. I tried my best to implement some of the features people are requesting and downloads are soaring. I couldn’t do much because I have a day job and only have the nights and weekends to work on the app. People starting telling their friends about the new cool app.

And here we are, four months down the line, I have 35K downloads, and for the first time, I feel what having a successful app is like. It’s a feeling of joy, that people find pleasure in your work, and actually use it. On a daily basis now, we have over 5K calls to the server from within the app and about 500 downloads per day on a bad day.

I know you have been dying to know what the app is all about. It is called NaijaLyricsWiki. It is an app that provides a wiki like functionality for lyrics of Nigerian songs. You can also download the song you are viewing the lyrics, you can share lyrics on facebook or send to a friend. And finally you can get latest entertainment news and gists from the app. If you have a blackberry, you can download from the app store. If you use an android device, you can download from Either blackberry or Android, you can download directly from The website is

Comments (6)

Simple Sorting Algorithms Implementations – Part 1

In the below, I will be presenting java source code of popular sorting algorithms. The problem with so many books I have read is that they don’t provide the simplest of solutions. I always consider myself an Hello World programmer. If I pick a new language, the first thing I look for is hello world, if I pick a concept, the first thing I look for is the simplest implementation, not the most optimized solution. NO. So when I look for implementations of algorithms, even if you are going to present me the most optimized algorithm, let me see the simplest, non-optimized implementation first.

When someone asked me why am I using for example, java.util.logging instead of log4j, I tell them, so far java.util.logging is working and I am yet to see a case I can not easily handle with it. So it is with these algorithms, let the reader/student see the simple solution and then present him with the problems with the simple solution, and then the optimized, more difficult to implement solution. If he likes, he can go with the simple implementation, when he finally discovered the problems with the simple implementation himself, it will be easier to understand the complex ones.

The programs below are very simple. Non of them have been optimized, they are meant to introduce to you these algorithms. You can take the code and optimize all you want. I also take care to use only simple data structures, no Lists, or Sets or any class in the collections package.

The below code are just segments of the full code. The important segments. The full source code is publicly hosted on Github

Finally if you want to read-up on these algorithms, please head to wikipedia

The algorithm below is based on the assumption that after every run through the array, the last element is already sorted.

for run1, the nth element is sorted,
for run2, the n-1th element is sorted,
for run3, the n-2th element is sorted, etc

	public void sortList(int n) {
		boolean swapped = true;
		while(swapped) {
			swapped = false;
			for(int i = 1; i < n; i++) {
				if (toSort[i] < toSort[i - 1]) {
					swap(i, i - 1);
					swapped = true;
			n = n -1;


	public void algorithm() {
		for(int i = 1; i < toSort.length; i++) {
			int key = toSort[i];
			int k = i - 1;
			while(k >= 0 && toSort[k] > key) {
				toSort[k + 1] = toSort[k];
			toSort[k + 1] = key;


	private void sortList(int startIndex) {
		int minIndex = findMinimum(startIndex);
		if(minIndex != startIndex) {
			int temp = toSort[minIndex];
			toSort[minIndex] = toSort[startIndex];
			toSort[startIndex] = temp;
		if(startIndex < toSort.length) {
			//recursively call sortList

	public int findMinimum(int startIndex) {
		int min = toSort[startIndex];
		int minIndex = startIndex;

		for(int i = (startIndex + 1); i < toSort.length; i++) {
			if(min > toSort[i]) {
				min = toSort[i];
				minIndex = i;
		return minIndex;

In the Part 2 of this post, I will show codes for MergeSort, QuickSort and HeapSort.

Source Code: Github

Comments (2)

Codename One Dynamic Ads Component

Codename One (CN1) really took off with a blast. Although still in beta, but loads of people are already using it for various apps, from banking to a mobile front for this. What is commendable is the ease with with you can build mobile apps that are truly cross platform without having to install tools for each platform.

If you are still wondering what CN1 is, please head to CN1 Website and read up about it for yourself.

I am going to be doing a series of tutorials or useful code snippets for CN1. Today we are looking at the ads component.

To use codename one ads, you need to register and have an account on inner active

Here are the steps to getting your ads on your CN1 app

  1. Create an account on inner active
  2. After login in, click the Add App tab and provide details for your app. The trick is to create different apps for different platforms so that inner active don’t go displaying a download app link on the appstore to blackberry users. You can also profile by age group and/or location.
  3. For every App you added like this, inner active will generate a unique key for you. Key this key.
  4. Now in your code, create an hash table that holds all the keys mapped to the specific platform and populate it. Then write a method as in below to add the ads component to the form.
    public static final Hashtable adKeys = new Hashtable();
    adKeys.put("rim", "[inner_active_rim_ad_key]);
    adKeys.put("and", "[inner_active_android_ad_key]");
    adKeys.put("me", "[inner_active_others_ad_key]]");
    public static void showAds(Form f) {
        Ads ads = new Ads(adKeys.get(Display.getInstance().getPlatformName()).toString());
        if (!f.contains(ads)) {
            f.addComponent(BorderLayout.NORTH, ads);

Now for every page where I want to show the ad, I just call the above method and pass the form instance. Notice however that all my forms are BorderLayout and the North part is reserved for ads.

If you want to however use any type of layout other than border layout, you can use this code to add the ads component to the top of the page

Ads ads = new Ads(Helpers.adKeys.get(Display.getInstance().getPlatformName()).toString());
if (!f.contains(ads)) {
f.addComponent(0, ads);

That’s it, you now have Ads. You can visit your inneractive dashboard to see how your App is doing.

Comments (6)

« Newer Posts · Older Posts »