Android Application Development

Android Application Development

Android application development is the process by which new applications are created for devices running the Android operating system. Such apps can be written using Kotlin, Java, and C++ languages using the Android software development kit, while using other languages is also possible.

A brief history of Android

The Android platform was spawned from the efforts of an organization known as the Open Handset Alliance (OHA), which had at the outset the mission of collaborating to “build a better mobile phone.” Today, if you visit the Open Handset Alliance website, you might think that their efforts were in vain, as the latest news item dates to 2011. However, what was started with that group of carriers, hardware manufacturers, and software vendors has grown into the world’s most popular platform. Is Google the “man behind the curtain” of the OHA? Maybe, but no matter. In the decade since its introduction, Android is offered in the market by many large players across the globe and across numerous industries. Samsung, also a member of the OHA, is the leading manufacturer of smartphone devices worldwide, thanks to Android.

Although a single device (the G1 device manufactured by HTC and provisioned on the T-Mobile network) started it all, Android devices are now available in virtually every market on the planet — not just for mobile phones.

It is beyond the scope of this article, but ask yourself if there is not a correlation between (arguably) the world’s most successful Internet/search company also being the driving force behind the world’s most popular mobile platform. More eyeballs view Android devices every day worldwide than any other single computing platform.

If you want to write code that can run literally anywhere in the world, then you need to learn about the Android platform, so read on!

The Android platform

Looking at Android’s breadth of capabilities, it would be easy to confuse it with a desktop operating system. Android is a layered environment, one that is built upon a foundation of the Linux kernel and includes rich functionality. The user interface subsystem includes everything you would expect from a mature operating system environment including windows, views, and widgets for displaying common elements like edit boxes, lists, or drop-down lists. The browser is both capable for general web browsing and available for embedding directly into your own application.

Android Application development In the past decade, the mobile web has been transformed by the adoption of smartphones across consumer and business applications, including Android. “Responsive” web technologies have made the utility of mobile devices greatly enhanced.

Figure 1 displays a simplified view of the Android software layers:

  • Applications: Built-in applications, such as phone, contacts, browser, and more. The specific applications vary by Android version and manufacturer. Commercial applications from marketplaces, such as Google Play, Amazon, and more. Side-loaded applications, including the ones you will build. You install these via USB cable.
  • Application frameworks, such as telephony manager, location manager, notification manager, content providers, windowing, resource manager, and more.
  • Libraries, such as graphics libraries, media libraries, database libraries, sensors, and so on.
  • The Android runtime is responsible for executing and managing applications as they run.
  • Linux Kernel, including power, file system, drivers, process management, and more. Figure 1. Android software layers

Android Application development boasts a healthy array of connectivity options including wifi, Bluetooth, NFC, and of course cellular connections on every network that you can imagine. Location-based services power popular mapping and navigation apps. Digital cameras have essentially retreated up-market due to the quality of the cameras found in modern smartphones. Android supports multiple cameras with the ability to capture full motion video. One of my favorite classes of applications is machine vision, where applications use the camera as an input device to perform inspections for manufacturing. Voice-based services make the modern Android device a virtual personal assistant.

If you can dream it, you can program it on the Android platform!

Clearly, Android is a capable computing platform, so let’s see what kinds of applications Android can run.

Application architecture

An important aspect of the Android application environment is that Android applications have historically been written in the Java™ programming language. However, you can also write them in a relatively new programming language from Google called Kotlin. This article focuses exclusively on Java, but Kotlin is gaining momentum and you might consider taking a closer look. Between the trend toward “newer is better” in programming languages (for example, Swift is overtaking Objective-C for iOS/Apple development) and the ongoing legal battle over where Java can or cannot be used, Kotlin will likely be the leading language for Android within a few years.

You can read more about the lawsuit between Oracle and Google about Google’s use of Java in its Android operating system in this Wikipedia article.

For now, Java is the incumbent technology. If you’re just starting out, Java is a safe place to work for a couple of reasons. First, there is a decade’s worth of Android resources on the web focused on Java. Second, Java is a language that still has life in it for other platforms – particularly server-side web technologies. As a classic object-oriented programming language, Java skills still matter.

Android Application developmen ? While it might not matter at this point, there are some interesting details around how Android applications come to life from their underlying source code. Again, in this article, our focus is on Java programming.

Java source code is compiled and formatted into bytecode, which represents the logic of an application but not the specific instructions for a particular hardware device. Similar to traditional Java environments, early versions of Android operated by converting these so-called bytecodes to hardware-specific executable code. This conversion magic is accomplished by using a Just-In-Time (JIT) compiler and takes place each and every time the application is executed. Once the JIT compiler has converted the code, it is executed in a virtual machine known as the Dalvik VM.

Beginning with Android version 4.4 (KitKat), the Dalvik VM has been replaced. The JIT compiler converts bytecodes to executable code directly on the device at runtime each time the application runs; the new approach is called Ahead-of-Time (AOT) compilation. With AOT compilation, the byte code is converted only once when the application is installed. This slows down the one-time activity of installing the application but gains the benefit of faster execution at run time when it really matters.

With AOT, we enjoy faster runtime experience with lower RAM requirements at the expense of more storage requirements. Considering the incessant decline in the cost of storage, this is an agreeable direction to move in for our mobile applications. Figure 2 contrasts the old and the new execution environments.

Figure 2. Dalvik VM versus Android runtime
Dalvik VM

Fundamentals of Android development

Regardless of the moving pieces of how applications get converted from source code to running code, from a programming perspective, there are some fundamentals to understand when starting out with Android development.

An Android application Development consists of one or more of the following four classifications:

  • Activities: An application that has a visible user interface is implemented via an activity. When you select an application from the Home screen or application launcher, an activity is started.
  • Services: You can use a service for any application that needs to persist for a long time, such as a network monitor or update-checking application.
  • Content providers: The easiest way to think about content providers is to view them as a database server. A content provider’s job is to manage access to persisted data, such as the contacts on a phone. If your application is very simple, you might not necessarily create a content provider, however if you are building a larger application or one which makes data available to multiple activities and/or applications, a content provider is the proscribed means of accessing your data.
  • Broadcast receivers: You can launch an Android application to process a specific element of data or respond to an event, such as receiving a text message.

An Android application is deployed to a device along with a file named AndroidManifest.xml. This file is required for every Android application and is essentially the cheat sheet that tells the operating system exactly how to interact with your application. The AndroidManifest.xml includes both the required class names and types of events that the application is able to process as well as the required permissions that the application needs to run. For example, if an application requires access to the network to download a file, this permission must be explicitly stated in the manifest file. Or, perhaps an application needs to access the camera. The user needs to approve that also. This approach of declaratively telling the user what the application is going to use is essential in this day of increasing privacy and security concerns. While you can quickly just accept software licenses, it is important that you pay close attention to what an app is requesting to access.

Enough background…let’s have a look at the development environment required to build an Android application.

Exploring Android Studio

The easiest way to get started with developing Android applications is to download the Android Studio application suite. You can download a copy of Android Studio for your preferred platform (Windows®, Mac OS X, or Linux) from the Android developers site. Android Studio includes tools for managing multiple platform-specific features with the sdkmanager and the ability to test your application on either a real device or the emulator.

There are older generations of development tools, including Android Developer Tools (ADT), which is the predecessor to Android Studio, and Eclipse with an Android Developer Tools plug-in, which was the predecessor to ADT. In essence, Android Studio is the third generation of the Android Integrated Developer Environment (IDE). There are also command-line tools and various continuous integration toolchains that permit the building of Android applications.

This article assumes that you are using Android Studio. Coding in Java within Android Studio is intuitive because it provides a rich Java environment, including context-sensitive help and code suggestion hints. After you compile your Java code cleanly, the components of Android Studio make sure all of the application is packaged properly, including the AndroidManifest.xml file.

Let’s take a quick look at the contents of the SDK.

The sdkmanager, which ships as an integrated experience of Android Studio, manages the download of the numerous elements of the Android SDK. Figure 3 shows a subset of the SDK installed on a Mac.

Please see our demo projects on Android Application Development by visiting out portfolio page

31 thoughts on “Android Application Development

Leave a Reply

Your email address will not be published. Required fields are marked *