Looking at Android Development? Start Here

Not long ago I started to trained myself by offering to work in an Android app. I hadn’t had any contact with mobile development beforehand, and navigating between the existing manuals is not easy.

The outcome of that experience was this guide. It serves as a map for understanding Android in the shortest possible time.

It was designed with developers like you in mind.

The Development Environment

If you are going to write applications for Android, you should use on Android Studio. It’s the official IDE to write, design, and debug quite easily.

There are a few things you need to do after you have installed the IDE,

The Basics of Android Development

Android applications are written in Java. You need an SDK to compile your code in an APK (Android package).

Android represents each app as a Linux user (Android is built on Linux). This “user” has a unique ID and permissions associated with it. Each app runs in its own virtual machine, isolated from the rest of the processes.

It is worth mentioning that each application follows a life cycle that depends on the process that runs in it, and not the other way around.

Components

A component is an atomic element of an app,

  • A component can be called individually as an entry point, or a component can call another, even across apps.
  • To implement a component, you first create a subclass of it.
  • Each component has its own life cycle.

The official Guide of Fundamentals contains more information and types of components. Subclasses appear listed in the Android technical documentation.

Manifest

The manifest is an information archive for the system. This file must exist in the project’s root and declare all the components it uses, the permissions it requires, compatibility with the system, Android functions that will consume them, and the external dependencies.

The Manifest Section in the Guide of Fundamentals contains examples of how to perform each of these statements. If you want to check the complete reference, check the guide for all the tags that you can use.

Just like you declare in your Manifest the components that the application contains, you can also add Intent Filters to a declaration. An Intent Filter tells the system that this component has the ability to receive an implicit intent (see below).

Fragments and Activities

These are two types of components that define the behaviour of the graphical interface of the application. An activity represents a screen, while a fragment represents a part of a screen.

Both are associated with a view (layout). They control the information that you see on the screen and enable interactions with the system and other components of the app.

You will definitively need to familiarize yourself with the Activities Life Cycle.

Keep in mind that you can refer to the Technical Reference of the activities (under the Summary section).

Services

Services are components that are kept in the background. They run within the same process as the app. They function independently of the interaction between the user and the system.

Services have their own life cycle but since they are contained in a process, they also depend on the life cycle of this process.

Click here for detailed instructions on how to create a service.

Context

Activities have a method to obtain the context of the application,

getApplicationContext()

The context allows you to use the application’s resources and classes. We can also make calls from it to launch an Intent or call other components.

The technical reference thoroughly documents what you can do with the application Context.

Intents

An Intent is a message that requests a specific action from a component. For example,

startActivity(Intent intent)

This call summons a screen. By means of the Intent parameter we provide the data required by the Activity.

startActivityForResult(Intent intent)

In this case, you will receive a response in the form of another Intent when the Activity that is called by running the following callback,

onActivityResult(Intent intent)

Intents can initiate a specific component or request an action to be resolved by a component that has the capacity to do so.

The Official Guide contains instructions for creating an Intent. You can also review the full reference at your leisure.

Storage

If you need to persist data, Android offers you several options,

  • You can store raw data in a key-value array
  • Save files physically in a device
  • Have a private, structured database (SQLite is the default)
  • Send data via the internet

These options are relatively simple to implement. Examples of each one can be found in the official guide.

Resources

Resources are data that the application will consume. They are packaged along with the app. It usually contains strings that are displayed on the screen, translations, logos, icons, fonts, layouts, and styles.

Each Resource in the app has a unique identifier. This is used by the app and can also be used by other Resources (e.g., XML resources).

I recommend a couple of very short readings before working with Resources,

This guide will help you to access a Resource, either from your code or from another resource.

Layout

A Layout is a Resource that defines the appearance of a Screen or Fragment. It is written in XML as a structure of graphic elements (or nodes) that have properties. These properties may contain references to other Resources.

To link an Activity to a Layout, you execute this instruction,

setContentView(R.layout.[your_layout]);

The Layouts are also nodes within your XML. There are different types which are explained in the guide.

Layouts have type which consists of a way to position the nodes it contains and the properties it can take (LayoutParams).

A Layout can be nested inside another Layout.

Finally …

I hope you found this useful. I hope it saves you time and effort that you can use to practice instead.

Focus Mode

Contact Request

Close

We will call you right away. All information is kept private