Writing Mobile Java Applications with the Android SDK
The Android operating system is open source and its source code was released under the Apache license. It is an operating system designed and built for mobile devices by Google. Built upon the Linux kernel, the design goals of the Android platform include: platform neutrality, open source, flexibility, and rapid development. Android is the most popular mobile operating system in the world. Note that Android applications run on the Dalvik Virtual Machine (DVM) instead of the JVM. The DVM is optimized to run on your mobile devices.
Before you can start working with the Android SDK, you should make sure that the Java Development Kit (JDK) is installed in your system. You should install the latest version of JDK in your system before your go ahead using the Android SDK. You can check the installed JDK version in your system by issuing the following command in the command window:
javac - version
You should also verify that the JAVA_HOME environmental variable is set to the JDK installation directory.
Before you start using the code samples illustrated in this article, you should download and install the latest version of Android Studio.
What Is Android SDK? Why Is It Needed?
The Android SDK is a software development kit for Android development that contains the necessary components for you to build Android applications. It comes as part of the Android Studio and includes many sample code examples to help you get started, and also an emulator for you to run your Android applications. The Android Virtual Device manager that comes with the Android SDK enables you to test your application with any version of Android. The Android SDK and Gradle tooling incorporate the needed tools to build, compile, and package Android applications. You can find the Gradle plug-in from this link.
For debugging Android applications, you can take advantage of the Android Debug Bridge (adb) tool that enables you to connect to any virtual or real Android device.
To program using the Android SDK, you need to have a basic knowledge of the Java programming language. To work with Android SDK, you can take advantage of the Android Studio or even a Java IDE such as Eclipse. The Android Studio is a popular IDE developed by Google for developing applications that are targeted at the Android platform.
The Android SDK Manager
Once Android Studio has been installed in your system, you can invoke the Android SDK Manager from Tools-> Android -> SDK Manager. You also can run the Android SDK Manager by double-clicking the SDKManager.exe file in the Android SDK installation folder in your system. You can use the Android SDK Manager to install and delete packages for a particular Android version.
Here's the list of the important packages in the Android SDK:
- SDK Tools
- SDK Platform Tools
- SDK Platform
- System Image
- SDK Samples
Components of an Android Application
An Android application is comprised of a collection of Android components, Java source files, and resource files that can be deployed as a single unit. The components of an Android application include the following:
- Application: You can have one Application class in your Android application that gets instantiated before any other component is instantiated.
- Activity: An activity may be defined as the visual representation of your Android application.
- Service: Services are used to handle background processing.
- Receiver (also known as Broadcast receiver): This is a component that is responsible for handling the communication between the Android Operating System and the applications. You can register a receiver to listen to messages. The receiver, in turn, gets notified whenever an event occurs. A receiver is notified by the Android Operating System when such an event occurs.
- Content provider: A Content provider is a component that provides a structured interface to your application's data. As an example, you can have a content provider providing an interface to accessing the data stored in the SQLLite database.
The Android SDK is comprised of a collection of sample projects with source code, development tools, an emulator, and also the required libraries that are needed to build applications that are targeted at the Android platform. This article presented a discussion on the Android SDK and its components.