Android App Development
This article aims to provide beginner-level resources to people trying their hands on Android Development for the first time.
- 1 Languages
- 2 Setting up the Environment
- 3 Fundamentals of an Application
- 4 Getting Started
- 5 See also
Android apps are primarily written in Java, XML and now Kotlin(sometimes C++ too), but you'll only need Java and XML to get started. If you're not familiar with one or both of these languages, it is recommended that you get a basic understanding before diving in. You might want to quickly brush through the following articles to gain some level of insight into these languages:
Setting up the Environment
- Microsoft® Windows® 10/8/7/Vista/2003 (32 or 64-bit)
- Mac® OS X® 10.8.5 or higher, up to 10.9 (Mavericks)
- GNOME or KDE desktop
- Java JDK5 or later version
- Java Runtime Environment (JRE) 6
- Android Studio
You can download the latest version of JDK(Java SE Development Kit) including JRE from the Oracle website and the latest version of Android Studio including the Android SDK tools from the Google Developers website.
Installing Android Studio
You can find the installation instructions specific to your operating system on the Google Developers website by selecting your operating system from the dropdown that appears. Installation instructions are pretty straightforward and you will find plenty of support for any issues that you might face by just Googling the problem.
Fundamentals of an Application
Android apps are written in the Java programming language. The Android SDK tools compile your code along with any data and resource files into an APK, an Android package, which is an archive file with an .apk suffix. One APK file contains all the contents of an Android app and is the file that Android-powered devices use to install the app.
The Android system implements the principle of least privilege. That is, each app, by default, has access only to the components that it requires to do its work and no more. This creates a very secure environment in which an app cannot access parts of the system for which it is not given permission.
App components are the essential building blocks of an Android app. Each component is an entry point through which the system or a user can enter your app. Some components depend on others.
There are 4 major components of an app:
- Broadcast Receivers
- Content Providers
Each type serves a distinct purpose and has a distinct lifecycle that defines how the component is created and destroyed. The following sections describe the four types of app components.
An activity is the entry point for interacting with the user. It represents a single screen with a user interface. For example, an email app might have one activity that shows a list of new emails, another activity to compose an email, and another activity for reading emails. Although the activities work together to form a cohesive user experience in the email app, each one is independent of the others.
You implement an activity as a subclass of the
Activity class. For more information about
Activity class, see the Activities developer guide.
A service is a general-purpose entry point for keeping an app running in the background for all kinds of reasons. It is a component that runs in the background to perform long-running operations or to perform work for remote processes. A service does not provide a user interface. For example, a service might play music in the background while the user is in a different app, or it might fetch data over the network without blocking user interaction with an activity. Another component, such as an activity, can start the service and let it run or bind to it in order to interact with it.
A service is implemented as a subclass of
Service. For more information about the
Service class, see the Services developer guide.
A broadcast receiver is a component that enables the system to deliver events to the app outside of a regular user flow, allowing the app to respond to system-wide broadcast announcements. Because broadcast receivers are another well-defined entry into the app, the system can deliver broadcasts even to apps that aren't currently running. So, for example, an app can schedule an alarm to post a notification to tell the user about an upcoming event... and by delivering that alarm to a BroadcastReceiver of the app, there is no need for the app to remain running until the alarm goes off. A broadcast receiver is implemented as a subclass of BroadcastReceiver and each broadcast is delivered as an Intent object. For more information, see the Broadcasts developer guide.
A content provider manages access to a central repository of data. A provider is part of an Android application, which often provides its own UI for working with the data. However, content providers are primarily intended to be used by other applications, which access the provider using a provider client object. Together, providers and provider clients offer a consistent, standard interface to data that also handles inter-process communication and secure data access. For more information, see the Content Providers developer guide.
The Manifest File
The manifest file can be thought of a declaration of all the components an app contains. It is formatted in XML, and is located in the root directory of the app. It is necessary for the app's functioning. It also has some other purposes, such as the following:
- Identifies any user permissions the app requires, such as Internet access or read-access to the user's contacts.
- Declares the minimum API Level required by the app, based on which APIs the app uses.
- Declares hardware and software features used or required by the app, such as a camera, bluetooth services, or a multitouch screen.
- Declares API libraries the app needs to be linked against (other than the Android framework APIs).
The Gradle Build System
Now, when using Android Studio, one does come across the term Gradle quite often. Gradle is the build system that Android Studio uses, to compile and run your application as an APK on a test device, and later package it for distribution. It runs using build scripts, a sequence of build instructions that tell Gradle how to build the app. The build.gradle file that is part of every android project on Android Studio is an example of a Gradle build script. It includes all libraries and dependencies that the app requires, in addition to specifying basic build information like the Android version.
A comprehensive blog, explaining Gradle and it's nuances can be found here.
Also, a nice post on SO explaining why Gradle is used.
While designing applications, it is important that all apps follow a similar structure with an aim of providing consistency to the end user. Material Design is Google’s conceptual design philosophy that outlines how apps should look and work on mobile devices. It breaks down everything — such as animation, style, layout — and gives guidance on patterns, components and usability. It provides a set of guidelines for developing applications that provide uniform experience through different platforms and devices. Apps that obey Material Design guidelines fit smoothly in the Android ecosystem and gives the users a sense of familiarity.
To get started with android development, here are some good tutorials that can make learning the ropes a bit easier, and faster -
- Google's own Getting Started Guide.
- A pretty well-done Udacity Course (can be a bit slow at times).
- Tutorials Point is another well documented tutorial, which covers most of the essentials.
- StackOverflow Documentation where you will find examples for almost all the topics you'll need. For starters, this is the Getting Started guide that neatly explains all the steps you need to start your first project.
- Android Blog by Bijoy S Kochar is also a very good tutorial which covers up the basics and also provides custom libraries for basic functions like internet access, file i/o and JSON parsing.