Wednesday, 5 March 2014

Fundamentals | Android Tutorial for Beginners

Android History: 

Android, Inc. was founded in Palo Alto, California in October 2003 by Andy Rubin (co-founder of Danger), Rich Miner (co-founder of Wildfire Communications, Inc.), Nick Sears (once VP at T-Mobile), and Chris White (headed design and interface development at WebTV)to develop, in Rubin's words "smarter mobile devices that are more aware of its owner's location and preferences". The early intentions of the company were to develop an advanced operating system for digital cameras, when it was realised that the market for the devices was not large enough, and diverted their efforts to producing a smartphone operating system to rival those of Symbian and Windows Mobile.Despite the past accomplishments of the founders and early employees, Android Inc. operated secretly, revealing only that it was working on software for mobile phones. That same year, Rubin ran out of money. Steve Perlman, a close friend of Rubin, brought him $10,000 in cash in an envelope and refused a stake in the company.

Google acquired Android Inc. on August 17, 2005; key employees of Android Inc., including Rubin, Miner and White, stayed at the company after the acquisition.Not much was known about Android Inc. at the time, but many assumed that Google was planning to enter the mobile phone market with this move.At Google, the team led by Rubin developed a mobile device platform powered by the Linux kernel. Google marketed the platform to handset makers and carriers on the promise of providing a flexible, upgradable system. Google had lined up a series of hardware component and software partners and signaled to carriers that it was open to various degrees of cooperation on their part.

Speculation about Google's intention to enter the mobile communications market continued to build through December 2006. The unveiling of the iPhone, a touchscreen-based phone by Apple, on January 9, 2007 had a disruptive effect on the development of Android. At the time, a prototype device codenamed "Sooner" had a closer resemblance to a BlackBerry phone, with no touchscreen, and a physical, QWERTY keyboard. Work immediately began on re-engineering the OS and its prototypes to combine traits of their own designs with an overall experience designed to compete with the iPhone.In September 2007, InformationWeek covered an Evalueserve study reporting that Google had filed several patent applications in the area of mobile telephony.
Eric Schmidt, Andy Rubin and Hugo Barra at a press conference for the Google's Nexus 7 tablet.

On November 5, 2007, the Open Handset Alliance, a consortium of technology companies including Google, device manufacturers such as HTC, Sony and Samsung, wireless carriers such as Sprint Nextel and T-Mobile, and chipset makers such as Qualcomm and Texas Instruments, unveiled itself, with a goal to develop open standards for mobile devices.That day, Android was unveiled as its first product, a mobile device platform built on the Linux kernel version 2.6.The first commercially available smartphone running Android was the HTC Dream, released on October 22, 2008.

In 2010, Google launched its Nexus series of devices – a line of smartphones and tablets running the Android operating system, and built by a manufacturing partner. HTC collaborated with Google to release the first Nexus smartphone, the Nexus One. The series has since been updated with newer devices, such as the Nexus 5 phone and Nexus 7 tablet, made by LG and Asus respectively. Google releases the Nexus phones and tablets to act as their flagship Android devices, demonstrating Android's latest software and hardware features. On March 13, 2013, it was announced by Larry Page in a blog post that Andy Rubin had moved from the Android division to take on new projects at Google. He was replaced by Sundar Pichai, who also continues his role as the head of Google's Chrome division, which develops Chrome OS.

Since 2008, Android has seen numerous updates which have incrementally improved the operating system, adding new features and fixing bugs in previous releases. Each major release is named in alphabetical order after a dessert or sugary treat; for example, version 1.5 Cupcake was followed by 1.6 Donut. The latest released version is 4.4.2 KitKat, which was released on December 9, 2013



This is Part 1 of a series of articles I plan to write to simplify the new paradigms introduced by the Android platform for developers.

The part 1 will only define and introduce the fundamental building blocks of Android. Later articles will provide sample code focusing on one aspect at a time, more to drive home to concept than to show any great programming skills.

From a developer's perspective, the fundamental building blocks / components of Android are:
1. Activities
2. Services
3. Broadcast Receivers
4. Content Providers.

The means of communication between the above mentioned components is through
1. Intents
2. Intent Filters

The User Interface elements are by using what are called:
2. Notifications

Now, having broadly classified the basics, I would like to give a simple definition for each of them, before we can appreciate the need for each of them.

Activity is the basic building block of every visible android application. It provides the means to render a UI. Every screen in an application is an activity by itself. Though they work together to present an application sequence, each activity is an independent entity.

Service is another building block of android applications which does not provide a UI. It is a program that can run in the background for an indefinite period.

Broadcast Receiver is yet another type of component that can receive and respond to any broadcast announcements.

Content Providers are a separate league of components that expose a specific set of data to applications.

While the understanding and knowledge of these four components is good enough to start development, the knowledge of the means of communication between the components is also essential. The platform designers have introduced a new conpect of communication through intents and intent filters.

Intents are messages that are passed between components. So, is it equivalent to parameters passed to API calls? Yes, it is close to that. However, the fundamental differences between API calls and intents' way of invoking components is
1. API calls are synchronous while intent-based invocation is asynchronous (mostly)
2. API calls are bound at compile time while intent-based calls are run-time bound (mostly)

It is these two differences that take Android platform to a different league.

    NOTE: Intents can be made to work exactly like API calls by using what are called explicit intents, which will be explained later. But more often than not, implicit intents are the way to go and that is what is explained here.

One component that wants to invoke another has to only express its' "intent" to do a job. And any other component that exists and has claimed that it can do such a job through "intent-filters", is invoked by the android platform to accomplish the job. This means, both the components are not aware of each other's existence and can still work together to give the desired result for the end-user.

This dotted line connection between components is achieved through the combination of intents, intent-filters and the android platform.

This leads to huge possibilities like:
1. Mix and match or rather plug and play of components at runtime
2. Replacing the inbuilt android applications with custom developed applications
3. Component level reuse within and across applications
4. Service orientation to the most granular level, if I may say

Now that the concept of intent has been introduced, let me get down to a more formal definition of Intent.

Intent is a bundle of information, a passive data structure that holds an abstract description of the operation to be performed. (or in the case of broadcasts, a description of an event that has happened and is being announced).

There are 2 types of intents which I intend to detail in the next part of this series. Before winding up part 1, I would finally also give you a formal definition of Intent filters.

Intent filters are the means through which a component advertizes its own capabilities to handle specific job/operations to the android platform.

No comments: