Let’s begin Android Programming

How do we begin with Android Programming… Hmm.. Let’s see

They say the best way to get a person to listen is to start with a damn good statistics

[caption id=”attachment_255" align=”aligncenter” width=”1292"]

Global Market Share for Smartphone OS

Global Market Share for Smartphone OS[/caption]

This pie chart does not need to be accompanied by more information unless you are blind. (which I hope you are not, because there will be lot of more visuals and code in this tutorial than words) Android has such large market base and variety of devices (Read phones, tablets, phablets, TVs, watches and what not) that it’s high time to get to Android developing whether it’s for helping people or just yourself

Learn more about Android History here: The Android Story

Look how Digital Trends compares the iOS and Android for best OS rundown.

Here is Bloomberg Business reporting Android acquisition from July 2005

Fun Fact : Google brought Android OS from Android Inc. for “at least” $50 million from Android Inc. who where actually trying to make an OS for digital cameras.

Enough with the stats… Now things are really gonna get interesting…

This tutorial assumes that you have already set up Android studio

If not, go to Installing Android SDK and follow the instructions to get started

Android Studio is the editor recommended by Google for Android App Development. Eclipse is rather outdated now and with a slew of new Features, Android Studio looks good to go.

If you still have issues with setting up Android studio, Refer to this Tutsplus tutorial that neatly describes the set up and features of android studio.

When you launch Android Studio, this screen will be up greeting you

[caption id=”attachment_295" align=”aligncenter” width=”814"]

Android Studio Welcome Screen


If you are starting for the first time, the Recent Projects will be empty of course!
(I have not been very imaginative with my naming scheme… I know)

From here, it is pretty straight forward, let’s Start a new Android Studio Project right away.

[caption id=”attachment_303" align=”aligncenter” width=”1069"]

Project Name

Hello World![/caption]

Now enter your Application name… I have named it Hello World. (Because of the convention and because it is what the program is going to be) Enter a random company name in the pattern


Now as you can see, the package name for the app is filled in automatically


What does the package name indicate?

All Android apps have a package name. The package name uniquely identifies the app on the device; it is also unique in the Google Play store. This means that once you have published an app with this package name, you can never change it; doing so would cause your app to be treated as a brand new app, and existing users of your app will not see the newly packaged app as an update.

Right now, it is no reason for you to worry. It is true you cannot change it once you publish the app (it would be a good idea not to name the package whatever.whatever then) you can always change it just before publishing. Here is a stackoverflow link for the paranoid.

[caption id=”attachment_319" align=”aligncenter” width=”1070"]

Choose your minimum SDK

The Minimum SDK Choice[/caption]

This would be a right time to look into Android’s history and versions

[caption id=”attachment_259" align=”aligncenter” width=”736"]


Courtesy: XDA Developers[/caption]

This list has already grown into Marshmallow and Lollipop.

Fun Fact: Google CEO Sundar Pichai reportedly told Delhi University students that Android N could be named after an Indian Sweet.

Getting back to our Minimum SDK dilemma, since this is our first app, let us choose to concentrate only on Phones and Tabs. Still which SDK?

The Min SDK acts as your low-pass filter. Google Play won’t show your app on devices running a platform version lower than its minimum SDK version. So why not just set the Min SDK to one and support everyone? Generally you’ll want to target as many users as you can there’s a cost associated with supporting some of these older versions: things like creating different execution paths around deprecated or update APIs or presenting a different UX to devices with different features. So
you need to balance the opportunity of expanding your audience with the cost of supporting those new users Also remember that each release introduced with it
new APIs and hardware support. So it may not make sense to make your app available to devices that don’t support your minimum feature set.

Watch this video from Google Enginners on Udacity to find out more.

Now when you select each SDK version, Android Studio automatically shows you the percentage of users your app is going to support. I’m going to go with ICS here, because I’m happy with 86% is users (currently) and I wouldn’t actually need any advanced features to do a Hello World Project.

[caption id=”attachment_333" align=”aligncenter” width=”1066"]


Blank or Empty?[/caption]

The Android Studio now asks to add an Activity.

Before we choose an activity, what exactly is an Activity?

An Activity is an application component that provides a screen with which users can interact in order to do something, such as dial the phone, take a photo, send an email, or view a map. Each activity is given a window in which to draw its user interface. The window typically fills the screen, but may be smaller than the screen and float on top of other windows

Read more about Activities here

Now as you can see on screen, there are different types of activity templates available. You any of them, but for the purpose of this tutorial, I will choose any empty activity.

Meanwhile there are two activities that spell the same, an Empty Activity and Blank Activity. An empty is empty (Not really.. We will look at that in a while) while a blank Activity contains a floating button that does no action.

[caption id=”attachment_355" align=”aligncenter” width=”1067"]


Name your activity[/caption]

An Activity is normally composed of a class specified by Activity Name and a layout file specified by Layout Name. We will let the default names stay for our purpose. Click Finish and let’s get to code.

[caption id=”attachment_360" align=”aligncenter” width=”1366"]


The Code Finally[/caption]

Android studio opens up activity_main and MainActivity.java in two tabs as the project build on Gradle.

Main Activity file is written in Java while activity_main is an xml file that specifies the layout on the screen.

Now all you have to do is run the project. (Wait.. I didn’t do anything? Don’t U worry.. Just run the code)

Click on Run. (Green play shaped button on the top or easily available in Run menu)

More info on Running and debugging your Project available here

There are two ways to run the Project, on a hardware device plugged on to your device or by an AVD or emulator like Genymotion

Genymotion seems cool and seems to be the trending solution with Android Developers worldwide.

Do it right and end up with this

[caption id=”attachment_380" align=”aligncenter” width=”174"]


Hello World[/caption]

Pretty clean. Isn’t it?

Welcome to Android Programming Developer!

We will analyse this code in out next tutorial.