App Development in Brief

Before starting a project, you should already have an idea what Android devices will be your target.

Most applications will target smart phones and tablets. However, the current Android release also allows you to develop apps for smart TVs and wearables.

Then, you need to decide what versions of Android you want to support.

Android was released in 2008, but at the time of writing this there are already 22 API levels available, level 1 to level 22.

–> Of course, the higher the level, the more features are available. However, many older phones and tablets do not run the latest Android and cannot run applications that target higher API levels than what are installed.

Fortunately, Android is backward-compatible. Applications written for an earlier version will always run on newer versions. In other words, if you write applications using API level 10, your applications will work in devices that support API level 10 and later. Therefore, you would want to aim the lowest API level possible.

–> Once you decide what Android devices to target and the API level you should write your program in, you can start looking at the API.

There are four types of Android application components:

  • Activity: A window that contains user interface components.
  • Service: A long running operation that runs in the background.
  • Broadcast receiver: A listener that responds to a system or application announcement.
  • Content provider: A component that manages a set of data to be shared with other applications.

An application can contain multiple component types, even though a beginner would normally start with an application that has one or two activities.

–> You can think of an activity as a window. You can use Android user interface components or controls to decorate an activity and as a way to interact with the user.

If you are using an IDE, you can design an activity by simply dragging and dropping controls around your computer screen.

–> **  To encourage code reuse, an application component can be offered to other applications. In fact, you should take advantage of this sharing mechanism to speed up development. For example, instead of writing your own photo capture component, you can utilize the component of the default Camera application. Instead of writing an email sending component and reinventing the wheel, you can use the system’s email application to send emails from your app.

Another important concept in Android programming is the intent. An intent is a message sent to the system or another application to request that an action be performed. You can do a lot of different things with intents, but generally you use an intent to start an activity, start a service or send a broadcast.

–> Every application must have a manifest, which describes the application. The manifest takes the form of an XML file and contains one or several of the following:

  • The minimum API level required to run the application.
  • The name of the application. This name will be displayed on the device.
  • The first activity (window) that will be opened when the user touches the application icon on the Home screen of his or her phone or tablet.
  • ? Whether or not you allow your application components be invoked from other applications. To promote code reuse, functionality in an application can be invoked from other applications as long as the author of the application agree to share it. For instance, the default Camera application can be invoked from other applications that need photo or video capture functionality.
  • What set of permissions the user must grant for the application to be installed on the target device. If the user does not grant all the required permissions, the application will not install.

Yes, many things require user permissions. For example, if your application needs to store data in external storage or access the Internet, the application must request the user’s permission before it can be installed. If the application needs to be automatically started when the device boots up, there is a permission for that too. In fact, there are more than 150 permissions that an application may require before it can be installed on an Android device.

Most applications are probably simple enough to only need activities and not other types of application components. Even with only activities, there is a lot to learn: UI controls, events and listeners, fragments, animation, multi-threading, graphic and bitmap processing and so on. Once you master these, you may want to look at services, broadcast receivers and content providers.