Welcome to Android! Part 2.

Hey! Welcome back! We have covered the basic environment setup and created a blank application in our last part. Before we actually begin coding, it is essential to understand how to use Eclipse and the project structure of Android. Let’s begin with the Android project structure.

Section 1 – Project structure:

Here is an overview of the project structure. Don’t panic, it’s really simple. We will go through all the important folders and understand their importance.

project structure

  • src – contains all your Java packages and files.
  •  gen – contains the files generated after your project is built
  • assets – contains the raw files used in your project. (sound files, videos etc.)
  • libs – contains all the external libraries required for your project. Libraries are packages/files written by other coders to help you. Yes, there are good people out there
  • res -> drawable – contains the generic images and xml files
  • res -> drawable-**dpi – You will notice 5 folders inside res named as drawable-ldpi, drawable-mdpi, drawable-hdpi, drawable-xhdpi, drawable-xxhdpi. Each folder holds images/xml files for a specific range of device resolutions and densities. We will be using these folders to adapt our application to the variety of densities and resolutions
  • res -> layout – contains all the xml files which create the structure of your Activities
  • res -> menu – contains all the xml files which make the menu in your ActionBar
  • res -> values – contains all the xml files which hold dimensions and strings accessed by your application

There are two important files we need to keep in mind :

  1. AndroidManifest.xml – contains the project’s permissions, declaration of Activities and Services. (Activities and Services will be covered in future tutorials)
  2. R.java – R.java is an auto generated file present in gen->”package-name”/. It contains unique identifiers (normally 32bit numbers) for elements in each category – drawable, string, layout, color, etc. The main purpose of R.java file is quick accessibility of resources in the project. If any resource modified, R.java file will be generated automatically.

That takes care of the important files and folders. You will find yourself referring back to the list for the first few times. Once you get used to it, you’ll know them like the back of your hand.

Section 2 – Exploring Eclipse:

Eclipse is our Android friendly IDE. Google has come up with their own IDE as well, it’s called Android Studio and uses Gradle (Eclipse uses ANT) for building projects. The ADT bundle comes with the latest version of Eclipse ADT which we will be using. This first thing we do is to activate the Dalvik Debug Monitor Server (DDMS) perspective. Go to Window->Open Perspective->DDMS

opening ddms

Eclipse will open the DDMS perspective for you which looks like this by default. If it’s not opened, you can click the DDMS button on the top right of your Eclipse window.

ddms default

What is this DDMS thing? It’s a great tool to help you monitor and debug your Android application. It provides a lot of information about your application’s performance and current state. Here are the most frequently used sections in the process of development:

  • Devices – This sections gives us a list of all the connected devices/virtual devices and the applications which are running in them.
  • Logcat – The Logcat is for viewing the messages printed in your program using the Log class. Messages written in System.out.print() will also appear here. You can select the Log Level using a drop down. Available choices are Verbose, Debug, Info, Warn, Error. You can also filter the log messages if needed.
  • Network – If your application deals with heavy network activities, you can view the network usage under this section.

We will need these for the forthcoming tutorials.



Welcome to Android!

Hey! Welcome to MyAwesomeSite.com! We will be cursoring through all the steps required to setup your PC (environment) so that you can build and run Android applications. We won’t just be monkeying steps or copying code, we will be completely understanding what is going on. The awesome people at Google have a comprehensive documentation at developers.android.com. It is up-to-date with the latest version and code of Android. This will be your bible for Android development here-onwards.

Note: We are working on a Windows PC

Section 1 – Environment setup:

We need the following things to get started:

  1. Java
  2. Android SDK
  3. An IDE like Eclipse
  4. Emulator/Phone

Go right ahead and download the latest version of Java from their official website. Install Java and modify your PATH and JAVA_HOME environment variables. These variables make Windows aware of your Java installation. Say you installed Java at C:\Program Files\Java\, your JAVA_HOME will be C:\Program Files\Java\jdk. And you will have to add C:\Program Files\Java\jdk\bin to your PATH environment variable. You can check if you have installed Java properly by typing java -version in your command line.

We now need the Android SDK and Eclipse.

The Android Software Development Kit (SDK) is required to build and test your applications. When we begin writing an application, the code will be in pure Java. While building the application, this code is converted to Dalvik code, which is understood by the Android OS. Once an application is built, it is packaged into an APK file. This file is used to install your application on a phone. Well, there’s more to it but we’ll get to that part later.

To help us code better, we need an IDE. We will be using Eclipse for this purpose. To make our life easier, Google already provides the ADT bundle. This bundle contains Eclipse + SDK tools + ADT Eclipse plugin + other geeky stuff required for building your application. The ADT Eclipse plugin makes your Eclipse compatible to understand Android projects/code.

Download the ADT bundle from their official website. Be sure to download a version compatible for your PC. If your PC is 32 bit, you will need a 32 bit version of ADT. Same applies for a 64 bit PC. It’s one heck of a download so keep it running while you eat.

Wash your hands and extract the package to a suitable location. We have to modify the PATH variable to make Windows aware of our SDK’s location. Say you extracted the ADT bundle to D:\Android\ADT, add D:\Android\ADT\sdk\platform-tools and D:\Android\ADT\sdk\tools to your PATH environment variable.

Now run the Eclipse from your ADT bundle and open your preferences.


A new dialogue will open. Select “Android” from the menu on your left-hand-side.


Eclipse is asking for the location of your SDK tools. You will find it inside your ADT bundle. If you have extracted the ADT bundle to D:\Android\ADT, your SDK tools will be located at D:\Android\ADT\sdk.


Press “OK” and you are done with the environment setup.

Section 2 – Creating a new project:

Go to File -> New -> Android Application Project

new projectA new dialogue will open.

new application nameChoose a suitable name for your application.

my first appHere we have chosen MyFirstApp as our Application Name. This will be used by Google Playstore when we upload our application.

The Project Name is used only by Eclipse to identify different projects in your workspace.

The Package Name is a unique identifier used to distinguish your application from all the other apps out there. The general convention is to reverse the name of your website. So, if your website is example.com, the package name will be com.example.myfirstapp (Notice we append the application name at the end).

Press the “Next” button. You will see another screen with some options. There’s no geeky stuff here, just simple options. Better not to touch any options here. Just make sure you have kept Mark this project as a library unchecked. If you keep it checked, your application will be used as a code base for another project. It will generate a .jar file and not a .apk file.

basic optionsPress the “Next” button. I know you may have the urge to hammer the “Next” button, but be patient. We promised to learn everything that’s going on, right?

The next screen gives us an option of configuring our app icon. The app icon will be used when you install your application. It’s used in the Google Playstore as well.

launcher iconAgain, no technicalities here. Just select your image file and play with the options. Once you like the result, click “Next”.

In the next screen you can select the basic layout of your application’s first page. This page is called an Activity. Similarly, all the pages you see in your application are Activities. We need a simple Activity for this tutorial, hence just select Blank Activity.

type of activityClick the “Next” button.

On the next screen you will see options to select the names of your first Java and XML files. Name them according to your convenience and click “Finish”

activity nameYou will now see a new Android project created with the name you had given. Eclipse automatically opens 2 files for you. In this case they are MainActivity.java and activity_main.xml. These two files work together to create a single page in your application. Huge applications have many such pages (Activities). For each Activity, you will have one .java file and one .xml file.

project createdThis completes the basic setup of your environment and Eclipse.
The next part covers the following topics:

  1. Exploring Eclipse
  2. Exploring the project folder structure
  3. Creating a virtual device to run your application
  4. Running your application on a virtual device

Dictionary of a Software Developer

If you have an eye, you come across very interesting observations at your workplace. People tend to interact in a particular fashion and they use very peculiar phrases which you gradually append to your own dictionary. What is interesting is these phrases are well masked and conveyed to save your ass from time to time. I’m pretty sure I might land up in trouble at my workplace after writing this but, here it goes:

1. “We will try”

We will try

People are generous enough to use 3 words instead of 1 (i.e. NO). Yeah, people can be nice sometimes.

2. “There’s an issue”

699This is the king of all phrases. Why? Because it covers everything from a color mismatch to deleting the client’s database. If you make it sound cool, your lead will think it’s under control and you can fix it. Use it wisely.

3. “We are working on it”


You will often find yourself using this along with #1. It means that you have a long to-do list of things like eating, gossip, day dreaming, staring at your desktop, eating and the mentioned work is somewhere on your list. Mostly near the bottom.

4. “We are testing it”


This is to buy more time for the items on your to-do list (refer #3).

5. “This is a client side issue” or “This is a server side issue”


The national sport for client side and server side developers is Table Tennis. The ‘issue’ never stops bouncing and ultimately ends up with  a ‘We are working on it’ tag.

6. “Let’s do this for now”

Concentrate on the last two words. You will be asked to build a stick figure (for now) and later be asked to modify it so that it should become RoboCop.


I’ll append to this list from time to time and hopefully I have helped you update your dictionary as well. All in all, people really do their work and that’s how a company runs. But, these phrases surely are a part and parcel of your daily developer lives.

What has gaming taught me?

It’s been 12 years since I played my first ever PC game. My dad had bought us PC way back in 1997 and it ran only DOS with some 64 mB of RAM. It wasn’t mean’t for us though. Me and my brother were little kids hopping around the machine hoping to figure out what it was and how it worked.


(without the CD drive)

After a few months, my uncle taught me a command which ran the only game on that PC – Prince. It was delight to see something moving on the screen at your command! The objective of the game was none of our business, we just wanted to see the Prince run around and fight.

Then came a few advanced ones like Dave 3 and our beloved Lion King. We were allowed to go to school on Saturdays and play in labs during the summer vacation. That was the period when we developed some ‘game sense’. The whole running and fighting was much more meaningful now. We had to keep our health green, we had to clear levels, we had to win. This same mindset was followed when we played on gaming consoles. Contra, Takken, Tanks, Street Fighter, Mario, Bomber Man, Circus – were all in our favourites list. Being the elder one, I got to play Mario and my brother was Luigi.

The gaming season continued for years till I reached 10th. Now was the turning point where playing games meant going against your parent’s wishes and not studying. Now was the time to study. I admit I was a little too engrossed in my own virtual world (quoting dad). Due to this habit, I just managed to scrape 90% in SSC. Not bad as some would say, but the additional percentages which I could have secured were paid as taxes to Diablo, Mortal Kombat and Counter Strike.

As of today, I have scored a lot of goals in FIFA, cruised through the streets of GTA, reversed the Sands of Time. I’m not a professional gamer nor can I say that I’m the best one around. Yet, my interest in that world has piqued every time I get my hands on a new set of games. Eventually I retrospected and wondered, where has this habit and virtual madness got me? What good has this done to me?

1. Anger management:

Hands down, this is the first point I would like to mention. When you play with people from across the globe, some are professionals and some are learners (noobs as the term is coined). Sometimes, these noobs manage to get under your skin so much that if the person was actually in vicinity, you would have sent him flying out the window. But you can’t do anything about it (except may be type a few cuss words and insult him which ruins the situation further). You have to gulp down that anger and keep yourself focussed on what is to come. He’s a learner and will eventually realize his own mistakes. There is absolutely zero intelligence in going all ballistic on him. You have to learn to work with the situation and do so with ice on your head.

2. Thinking on your feet:

Desperate situations require desperate actions. And in the gaming world, these situations arise every minute. You never know when a person with a machine gun with pop out of nowhere and plant all his bullets inside you. You have to be alert every step you take and be ready to take decisions in a fraction of a second. You have no time to stand in awe of the situation, you either do your thing properly or get kicked out by the leader. I have got kicked out a lot. Now I do the kicking. Give yourself some time and practice, your reflexes and decision making skills will take your miles ahead.

3. Perseverance

This trait is seen in almost every gamer I’ve met till date. They do not give up. They don’t care how dire the situation is. They don’t care if their team mates are falling into pieces. They keep walking steadily and with that inspiration, their team follows them to victory. The belief that you can win is much stronger than your skillset. Learning not to throw the white flag is a long gruelling process. You will face 100 lose before 1 sweet victory. Those loses, may be due to a weak team or due to your own faults. And do you give up? Hell NO!

4. Team work:

Not every game is GTA where you can hide 10 weapons in your pants and blast a helicopter out of the sky. Especially in MMORPGs, you are thrown into a team with players from another hemisphere and are required to play in coordination with them. You have never met them(and probably never will) and are expected to work as a team to achieve your objective. Sounds difficult as it is, gamers around the globe pull off this feat every single day and some do it effortlessly. How? Experience, practice and a genuine will to understand their team’s thought process.

5. How to let it go:

There will be no limit to the number of times you lose or get insulted. People may not be as understanding and mature as you are. There are assholes out there who bluntly play to insult others and seek please in doing so. You will meet such people once a while and may be it’s one of your bad days. Prepare yourself for the worst blasphemy. Initially, you will feel helpless and down. There will come a time when you realize that by reacting, you are fuelling the fire. You cannot change that person. But, what you can do is not to give a damn about his existence. You may lose or win the game, you may be insulted for a very small mistake by the whole team. But, does all this matter the next game? You can begin afresh. There’s no point in clouding your head with those moments. Never give them much importance and the next round you will own the game.

Go for it


Gaming is good or bad depending on how you let it affect your life. You can cruise through impossibilities and be a winner if your perspective is right. If gaming is affecting your life too much, go for the shutdown button. Your lessons are waiting to be learnt on one turf or another.

 Image courtesy: www.neverdc.com

Why Not To Loathe Superman

We are all fascinated by superpowers. And people who are bestowed with them enjoy privileges of the highest order in the comic world (Some are outlaws too). In the superhero world, be it Marvel, DC or anywhere else; there are two kinds of superheroes – One, who are born that way. Two, who are forced by circumstance (or a failed lab experiment).

If you ask my personal favourites, I would list them as Batman, Wolverine and Iron Man. Two of them are self-made and Wolverine would stand out as a successful lab experiment (for a change). There is one character who generates a lot of ambivalent feelings in the crowd. Some like him, some just dismiss him – “Big deal, he’s born with those powers.”

He has been gifted inhuman strength and many other powers from the moment he was born. I’m talking about Superman. You might have noticed that I’m trying to stress on the fact that he “was born” with these. The earth’s sun allows him to harness all these powers and make him what he is – The Man of Steel.

The Justice League

Let us take some time and step into the shoes of the young boy named Clark Kent. After his spacecraft crashed into Smallville, he was adopted by Jonathan and Martha Kent. His natural self became more and more evident with age. His powers surfaced and he was disciplined well under the Kent’s to be the fine man he is. Throwing cars, punching through buildings and burning through steel was all a part of the daily routine to save the day. It has been shown so effortlessly in comics that we tend to forget his struggle to blend in with us earthlings. Yes, I said STRUGGLE. Why? Because, you cannot even begin to imagine how it is like to possess such power.

i. Superhuman strength:

Imagine you have the meat and muscle of Superman. What would you be able to do? Lifting cars, buildings, army tanks and anything you can get your hand to. You can lift a whole god-damn planet! Seems amazing doesn’t it!?

Now after a long day of saving the world (I’m assuming you are a good person), you decide to meet up with a few friends in your alias, as a normal human. What is the first thing you do when you meet your friends? You either shake hands or hug them. Hold on for a moment, you have superhuman strength. Aren’t you afraid to crush your friend’s hand into cosmic dust? Does it strike you that if you hug a person, you might as well merge their ribcage and spine into one bone?

Imagine trying to control your power every single second of your life. To get a glimpse of his peak strength, you can quickly go through this insightful video by VSauce.

ii. Superhuman sense of smell and hearing:

As they quote “He can hear a bee buzzing in the next city”. If that is true, you will be able to hear birds chirping, rivers flowing, tectonic plate movements, people talking (probably about you), cars honking and aircraft engine sounds to list a few things. All of these with zero loss in quality. You will feel like listening to a radio which is subscribed to every channel in the frequency spectrum!

What are the implications? A person cannot process so much data without setting definite priorities. If you decide to listen to your girlfriend’s sweet voice for a few minutes, a couple of hundred people would lose their lives in a plane crash just because you weren’t listening to the right source.

I leave it to your imagination to decide what your nose may smell with those powers.

iii. Self Control:

You are the strongest, fastest and the most intelligent being present on earth. Also, you are the last living person of your exquisite race. Don’t you feel like god? No one would dare to question your actions. You are free to roam anywhere on the face of the earth. No one will even think of challenging you (Except a few supervillians and Darkseid. Darkseid and Superman kill each other by the way).

If all this power doesn’t get to you, then you are a saint. What can possibly stop you from ruling over the world? You can dictate the rules. You decide who wins elections. You decide everything. Eventually, people will despise you and your tyrannical rule and you will go down in history as the next Adolf Hitler.

Clark’s parents and their taught ideals have prevented this. Self-discipline does not come easy.

I’m sure by now you are inclined to think that being Superman is a mammoth task. There is a reason why he is called The Man of Steel and it’s not just because of his strength. “With great power, comes great responsibility.”


What to do when everything looks in place but still doesn’t work out?

We all work our asses out trying to do our job well, to carry out our responsibilities, to make sure we are moving forward, to develop ourselves to face the world one day. Each one of us is inspired in some way. One friend of mine wants to cook and run a hotel which he owns himself. Another friend wants to develop something which will change the world (and of course earn him billions.) But, there are times when everything ‘seems’ fine but things still aren’t working out or progress is slow. Now, my experience comes with coding, loads of it cocktailed with numerous mistakes throughout the years. The following points are purely metaphorical, but I am sure they will fit in many aspects of your life.
Mike Ross

What do you do when everything seems in place and yet, you cannot work your way out of it?

1. Remember who wrote the code. (Remember who created the situation)
You wrote those lines, you know what belongs where, how it got there and why it got there. Don’t be overwhelmed after hours of pondering and re-thinking what can be wrong. The answer is just playing hide and seek in your head.

2. Re-analyze
Have you done this already? Oh well, the problem seems a bit persistent. How about we try some more? This time with a different approach. Quoting Harvey Specter from the remarkable TV show Suits –

“What are your choices when someone puts a gun to your head? What are you talking about? You do what they say or they shoot you. WRONG. You take the gun, or you pull out a bigger one. Or, you call their bluff. Or, you do any one of a hundred and forty six other things.”

Don’t take NO for an answer, even from computer code.

3. Go back to 1st grade
Ask yourself elementary questions. Get as stupid as you can, do it loudly. People think what they want any ways, so why not let them think you are crazy? Everyone is (including me.) These elementary questions will make sure you are completely aware of the situation at hand. And in this case, your code. If you can answer these questions then let me tell you that you are already half way through. If you cannot, then it’s probably time to go back to the forum from where you blindly “Ctrl + C”ed it.

4. Visit the site which has all answers.
You guessed it right. http://www.google.com. I have a mentor who doesn’t entertain silly questions. If we are being a bit ignorant, he will just dismissively ask us to Google it. And he is right in doing so. Research about your problem before you seek external help. There is a 99% chance that someone else might have faced the same ‘silly’ issue.

Many a times it is just a minor typo or a missing semi-colon. And if you are lucky enough, you might have found a bug in the framework. (Time to shout in forums!)

5. F R I E N D S.
You will not be disappointed with this one. We probably tend to overlook certain details after hours of staring at the same piece of code. We take certain aspects as granted and under our nose, those are the trouble makers.

A new set of eyes will lock on to the issue probably better than you can (after 5 hours of continuous work). You also have someone to bounce ideas with and your chances of solving the problem are doubled. Some advice and a bit of humour will set you on the right path. That’s what friends are for.

6. Take a break soldier
You need it now. Take your mind off the problem for a while. Have some coffee. Go and talk to the cute girl you like on the next desk. (Distractions are not advisable unless you know it is only temporary). After a nice walk in the park, you are recharged for the battle again. Yes, you have to get back and solve the god damn error.

7. Don’t effing give up
You are not allowed to give up. You are probably working on the project of your lifetime. You take responsibility for what is launched and what is not. Make sure that you are sweating blood before you go and tell your Boss that it cannot be done. You are not alone in this, people around you, your colleagues depend on you for that jQuery feature. You do not hold the rights to disappoint them.

Imagine what it will feel like after you have crossed this desert. Do you like that feeling? Well, you have to work for it. Keep driving yourself forward, keep motivating yourself and others around you. Eventually (after you found the missing semicolon), the code will run and you have my permission to dance around the office.

Kuch meetha ho jaye!

I logged out from office early owing to my weakness and expected fever. I wasn’t in a hurry at all. Drove my bike out of the parking lot and slowly accelerated towards my doctor’s clinic. The evening office traffic was heavy and I just had to get to Dadar from Chembur. After the doctor’s consult, I took off for home and this is where I was going to part take in a short and surprising incident.

Near the left turn from Sion hospital I was blind sided by a Tavera and missed the red light. I knew traffic police would be waiting to feast on this opportunity and I was right. That road wasn’t new to me and I had no doubt they were waiting patiently for drivers who forget their brakes. I saw the hand asking me to park aside. I had unintentionally missed the light, but I was at fault too.

“Ya bajula Saheb, gaadi thaambva.” (Come aside Saheb, halt your vehicle).

I had no option. I parked quietly besides another victim and waiting for his judgement. He just gave me a casual look hinting towards my license. This was my second encounter with a traffic police officer. The first one was pretty short so I’ll fit it into one sentence – I was driving home at midnight and one officers just casually stopped me to ask my name, twice(No rules broken, mind you!) and then he let me pass.

This wasn’t going to be so easy. I took off my helmet and glasses and calmly handed over my license and waited there resting on my bike. I felt weak, physically and it was evident from the way I stood. I just wanted this to end and get home. I started to convey what had really happened –

“Ti Tavera khup javalun geli and mala signal dislach nahi, mala disla asta tar thamblo asto mi.” (That Tavera went past very close to me due to which I was blind sided. If I would have seen the signal I would have stopped)

“Mi fakt tumhalach nahi thaambavlay, to bagha tyachi gaadi pan ahe thaambleli.” (I haven’t jut  stopped you, look there’s his vehicle as well)

“Kaka, mala kharach disla nahi signal.” (Uncle, I really couldn’t see the signal)

“Mala maajha kaam karava lagel Saheb, signal konalach todaicha nasto.” (I have to do my job Saheb, no one want’s to break signals)

“Tumcha kaam mala samajta pan mala taap aala ahe ani office madhun lavkar nighun doctor kade gelo hoto. Taap alay mala.” (I understand your job but I had gone to consult my doctor after leaving my office early today. I have a fever)

“Taap ala tar kashala gaadi chalavta Saheb??” (Why drive when you are not feeling well??)

“Kay ilaaz nahi ahe Kaka, office la javach lagta.” (There’s no way out, we are obliged to work in office)

“Aamcha pan kahi ilaaz nahi. Aamhala sangtat – Jaa 20 license gheun ya!!” (Even we are helpless. We are ordered – Go and get 20 licenses!!)

“Tumhala tumcha kaam karava lagta, pan mala kharach signal nahi disla.” (You are bound to your work but, I really couldn’t see the lights)

“Paise bharun jatay tar bola.” (Talk to me only of you are paying the fine)

“Kaka, gaadi navin ahe, mala signal todaichi haus nahi ahe.” (Uncle, the bike is new, I really have no motivation to break rules)

“Bara, 50 dya.” (Okay, give me 50)

I quietly took out my wallet and handed over a 100 rupee note to him. I had no idea whether I was supposed to wait for him to return the change or just ride away and thank god that I didn’t have to pay a hefty fine.

He asked me to wait.

He was handling another case during which he was handed over 2 bricks of Dairy Milk by his colleague. He asked the same fellow to return my change and stood behind my bike. I took my change and I was about to leave but noticed him handing over a piece of the chocolate to me! I denied. But, I had to accept it in the end with his words “Ghya chocolate. Taap alay, jara bara vaatel.” (Have this chocolate. You have a fever, this will make you feel a bit okay)

Startled and relieved, I drove away.