Welcome to your guide to Android app development! This post series aims to teach the basics of Android app development in Android Studio using Java programming language. I assume that you don’t have any Java or Android programming experience at the start of this post series.
I am going to explain every bit of app development in simple terms. You‟ll start from scratch and will be able to convert your ideas to your own apps after completing this post series.
A single post series obviously cannot make you the best expert on a platform or programming language however you‟ll have a solid background and hands-on experience in Android app development with this post series.
Android apps had been developed using Eclipse integrated development environment (IDE) with Android Development Tools (ADT) plugin in the past. However, Google introduced Android Studio as the official IDE for Android app development in 2014 and this IDE became the standard. The latest stable release is Android Studio 2.2, which will be used in this post series.
The Android Operating System
Let‟s overview the fundamentals of the Android operating system and the related concepts before starting our programming journey.
The Android Operating System Android is an open-source mobile operating system. It is a variant of Linux hence providing extensive security, modularity and productivity at the mobile device level. Android is developed and maintained by the organization called “Open Headset Alliance” (OHA). OHA was established in 2007 with Google being its foremost member. OHA includes a lot of prominent hardware and software companies.
Originally, Android was created by a company called Android Inc. Google acquired this company in 2005. After then, Google made it opensource and Android gained a big momentum. Android has the market share of around 85% in 2016 as shown in Figure 1.1 (data source: http://www.idc.com/). Considering this market share, it is obviously rewarding to invest in Android app development
Android has seven major releases each having several minor revisions. In order to follow these versions easier, developers name them with cookie names. The popular versions of Android are Kitkat (Android 4.4), Lollipop (Android 5.1) and Marshmallow (Android 6.0) (https://www.statista.com/statistics/271774/share-of-android-platformson-mobile-devices-with-android-os/). Nougat (Android 7.0) is also gaining popularity. Android becomes more capable as the version goes up. However, we have to be careful about selecting the version during app development because not every device uses the latest version. If we develop an app for the Lollipop, it may not run on a device which has Froyo installed. Fortunately, Android Studio enables us to select set the compatibility.
Android is utilized not only in smartphones but also in tablets, netbooks, digital television boxes, handheld game devices and even in single board computers such as UDOO. Therefore we first need to select the target device(s) and version(s) before developing an app.
How do Android Apps Work?
There are different ways the programs run on various platforms. The lowest level software can be written in machine code that runs directly on the microprocessor.
Since it is difficult to develop complex applications in machine code, operating systems are used. Operating systems provide a communication and control layer between the application software and the hardware.
If we want to develop a native application for running on a specific hardware/operating system, we have to do this using a compiler and linker.
Compiler and linker take the source code and creates the executable file that actually runs on the operating system. For example, if we want to develop an application in C++ programming language, we have to utilize the compilation/linking process.
The main advantage of native applications is their speed. However, the disadvantage is the incompatibility across different platforms.
For example, we cannot run a native Windows application on Ubuntu and vice versa. Virtual machine concept is developed to overcome this limitation.
A virtual machine is a software that runs on the operating system and provides an abstraction to the developer.The application software runs on top of the virtual machine.
Therefore, as long as a computer has the virtual machine running, the application software can run on that computer independent of the hardware and the operating system.
A good example is the Java Virtual Machine (JVM). JVM runs on almost all operating systems and platforms. Therefore, when we develop Java software, it will be run on the JVM independent of the operating system/platform.
The obvious advantage of developing apps that run on virtual machines can then be stated as: “develop once and run on all platforms”. However, applications running on virtual machines are slower than native applications. The general development process of virtual machine applications is summarized.
Similar to Java applications, Android applications also run on a JVM. There are two special virtual machines used in Android: Dalvik Virtual Machine (DVM) and Android RunTime (ART).
These are specialized JVMs which can run on low system resources. The .apk files (executables of Android apps) actually run on these virtual machines.
DVM has been the default runtime environment (~ virtual machine) until the Lollipop release (Android 5.0). ART is introduced by Android 4.0 and has been the default VM as of Android 5.0. DVM and ART basically do the same job: running Android apps independent of the platform.
The main advantage of ART over DVM is the utilization of a concept called Ahead of Time (AOT) compilation instead of Just in Time (JIT) approach. In AOT, apps are compiled during installation hence they load
faster with lower CPU usage. On the other hand, JIT compilation provides lower storage space consumption with relatively long loading times.