Click here to Skip to main content
15,911,707 members
Articles
(untagged)

Android for complete beginners: Article 1 Introduction.

Rate me:
Please Sign up or sign in to vote.
2.22/5 (2 votes)
26 Aug 2014CPOL5 min read 7.4K   5   1

Why AndroidTM ?

In the mobile market-place, from a developer perspective, there are three main players.

  • Google, for cross mobile platform access through one development environment, Android.
  • Apple, proprietry platform, with various formats.
  • Microsoft, best known for Windows applications through Visual Studio, but extending this onto phones and tablets.

Before asking how Android shapes up to the competition; why develop apps?

It is familiar at the end of a commercial to hear the refrain "available online, or download the app". But why both, clearly a mobile device needs an operating system, but once you have a browser installed, what is the advantage of duplicating a webpage to an app.

There are two answers. First, commercially, a supermarket chain wants you to use there service online, but with an app they have bound an icon shortcut to your tablet-top. Second, technically, an app has full access to the device that a website does not. [But note that with web caching and local storage, website based applications can be quite sophisticated.] However sensors, graphics accelerators, and other device hardware are still more accessible from an app than a web browser.

So there is a demand for: apps to support online businesses, games, and apps that leverage device hardware efficiently.

Why choose Android?

Its a very popular mobile platform, it uses the Java language which is similar to many other languages that developers are familiar with. It is dedicated only to the mobile environment and is as straight forward as possible. That is not to say it is easy, however it is possible to learn.

Why this course?

This is a beginner introduction to Android, requiring very little prior knowledge. We will try to put over the key concepts, with a few simple examples.

Hence in this introduction section some basic concepts will be introduced. Later we will look at installing the tools and using them to build apps.

For full documentation you can see the References section, next, after which comes the introducion to Android.

References

Android Developer Website

http://developer.android.com —This contains the fully comprehensive state of the art guidance on android development.

Books

http://www.apress.com/9781430231561 Learn Java for Android Development, By Jeff Friesen—Java language but without android applications, it is a preparation for Java and OOP

http://www.apress.com/9781430239307 Pro Android 4, By Satya Komatineni , Dave MacLean—Latest in Pro Android the series [circa Ice Cream Sandwich]. Covers many android topics.

Android

The Architecture

An Android device runs the Linux operating system, a beginner developer does not need prior experience. The Java language is required, prior experience would be an advantage, but this series will assume none. An essential part of Java executables is that they run in a virtual machine, this separates the hardware from the software enabling cross platform usage. In Android each application runs in its own Davlik virtual machine, but no technical knowledge of this is required. Android Libraries–dedicated to tasks often required in mobile applications–extend Java with open-source code. The free Software Development Kits and documentation, make it very accesible.

The Mobile Environment

Not only is Android across many mobile platforms, it provides an environment for a multitude of apps. However as resources are limited, the lifecycle of apps, needs to release resources in controlled fashion, as one is closed and another opened. Also applications can delegate functionality to other applications. For example showing a picture or guiding a user to an online help manual at a specific url.

Intents, Activities, Life-cycle

To understand how Android achieves delegation of tasks we need to understand Intent's. In a traditional PC desktop the method to launch an application is to find the executable or a link to it, and launch that.
For example: myApplication.exe

However in Android the executable and the launching process are separated. This is achieved with Intent's, these are used throughout Android. For example Icons on Android initiate an Intent, this type of Intent directs the application launcher to the main entry point of the application.
 
Generally speaking actions can be initiated by the user, this causes the creation of an Intent, which allows separation of the subsequent handling, by an application, and the request.

This allows the possibility of an action request to be handled by any appropriate application. To control which application handles an Intent, an Intent Filter is be used. When launching an application, this Intent Filter effectively links the icon to the executable.

A final piece of essential terminology is Activity, in fact Activity is the Android term for the basic component of an application. Put another way, if an action is requested some kind of activity is expected. So we have the following summary of a procedure that happens throughout Android.

User interaction requests > ACTION  > Intent  > INTENT FILTER  >  Activity

Activities may also beget their own requests. How to manage the lifecycle of all these activities? Again compare to a traditional PC desktop, where once open many applications are left running until its time to leave the office and shutdown, only to save electricity. But in Android the operating system is constantly managing resources.

Therefore built into Activities are methods which run at various transisiton points while the operating system manages its Activities. These special methods, which a developer uses to take care of relevent procedures, connect a pattern of states known as the Activity Life-cycle.

For example while a user looks at a 'now playing' music Activity, it may be time to save settings to a database in the previous app, however fully closing a database can wait until shutting down that Activity. So we have two states: Running [This app is on top], and Paused [This app is partly hidden, another app is in front], at the transition point a save could take place.

The states of a simple Activity startup are Created-Started-Running. The states of a simple shutdown are Paused-Stopped-Closed. The Activity Life-cycle forms a ladder:

Running    -------->   onPause
  onResume  <-------- Paused
  |                    |
Started                onStop
  onStart/onRestart <- Stopped
  |                    |
Created                onDestroy
  onCreate  <-------- Closed

The methods (bold) act as distributed entrypoints for the code. Clearly onCreate will be most important. But note that Android can go across the ladder too, for example when pausing and resuming an App, without completely closing it.

Summary

 

This article introducted some basic concepts. Now we can answer the questions: What is an Activity? What is an Intent? We can also describe the Activity Lifecycle and the Android architecture.

Before we get going, we need a Development Environment, we will discuss this in article 2. Then we can have a look at real code.

History

Version 1

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 2 Pin
Richard MacCutchan1-Sep-14 0:18
mveRichard MacCutchan1-Sep-14 0:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.