Browse by Domains

Android Tutorial – Everything You Need to Know

android tutorial

Android is an operating system developed and designed for mobile devices like smartphones, tablets, set-top boxes, televisions, etc. It is based on Linux and is an open-source operating system.

In this tutorial, you will learn about the basic concepts and understanding of the Android Operating System.

Introduction to Android

As mentioned earlier, Android is a Linux-based open-source operating system for various mobile devices. It was developed by Open Handset Alliance and sponsored by Google.

Android was founded by Andy Rubin, Rich Miner, Nick Sears, and Chris White in Palo Alto, California in October 2003.

Google released the first beta version of the Android Software Development Kit (SDK) in 2007 and the first version of the Android i.e. Android 1.0 was released on 23rd September 2008. After this total 19 versions of Android have been developed so far. The latest one is Android 11 which was recently released on 08th September 2020.

Android is a free and open-source operating system whose source code is available under free and open source software licenses, which is mainly under Apache License.

Features of Android

This powerful operating system comes with some great features that are listed below:

1. UI (User Interface)

Android was developed with a beautiful and easy to use User Interface (UI). It provides different pre-constructed UI components, for example, structured layout objects and UI controls that permit you to fabricate the graphical UI for your application.

Android OS also provides other components for special interfaces such as dialogs, notifications, and menus.

2. Storage

This operating system uses SQLite for data storage purposes. SQLite is a ‘Relational Database Management System (RDBMS)’ which is contained in a C library.

3. Connectivity

Along with some standard and basic network connectivity, Android provides Bluetooth, Wi-Fi, NFC, P2P, SIP and USB to interact and connect with other devices.

4. Messaging

Android OS provides SMS (Short Message Service) and MMS (Multimedia Messaging Service) to send short text messages, videos, photos or audios to other devices.

5. Multi-tasking

This operating system comes with a feature of Multi-tasking so that the users can use multiple applications simultaneously at the same time.

6. Media Support

Android supports different file types and formats including Audio formats: MP3, FLAC, AAC LC, AMR-NB, MIDI, Vorbis, etc. Video formats: AV1, MPEG-4 SP, VP8, VP9, etc. and Image formats: JPEG, PNG, GIF, BMP, etc.

7. Multi-touch

Android provides a great feature of multi-touch from which you can touch the screen with multiple fingers/ pointers at the same time.

8. Web Browser

Android OS comes with a Google Chrome Web Browser with V8 JavaScript engine supporting HTML5 and CSS3.

9. Widgets

There are many widgets which are available in an Android OS which are resizable, so users can expand them or shrink them to save space.

These widgets are very useful as they are the types of shortcuts that can be used and operated from the home screen itself.

10. Multi-language

Android supports multiple languages so that the users from all over the world are able to use this operating system. It supports single direction and bi-directional text.

11. Android Beam

With the Android Beam file transfer feature you can share small or large files to other devices. This is a NFC-based technology with lets you share files just by touching the two NFC-enabled devices together.

12. Firebase Cloud Messaging (FCM)

Firebase Cloud Messaging (FCM) is a feature that lets you send messages at no cost. Earlier, this feature was used through Google Cloud Messaging (GCM), but from 29th May 2018 it has been removed and replaced by Firebase Cloud Messaging (FCM).

With FCM you can send notification messages or data messages, send messages from client apps and distribute messages to your client app to single devices/ to groups of devices/ to devices subscribed to topics.

13. Wi-Fi Direct

This technology is used to connect devices directly to each other via Wi-Fi without an intermediate access point. It uses a high-bandwidth peer-to-peer connection to pair devices when each device supports Wi-Fi P2P.

Applications of Android

Android applications are developed either through Java or Kotlin language using the Android SDK (Software Development Kit).

After these apps are developed, they can be made available on Google Play Store, Opera Mobile Store, Mobango, F-droid and the Amazon Appstore.

Without a doubt, Android is the largest installed OS and is growing very fast. Millions of android devices are activated every day.

Below in this tutorial, you will learn about android app development. But before this, just take a look at some of the different categories of android applications.

Categories of Android Applications

  • News
  • Sports
  • Music
  • Business
  • Books
  • Multimedia
  • Social Media
  • Lifestyle
  • Shopping and many more

Environment Setup

So, here we are with the most important section of android application development i.e. the Environment Setup.

The first and foremost thing you will need while developing android applications is a Computer or Desktop. Android applications can be developed on either of the following operating systems:

  • Microsoft Windows XP or later version.
  • Linux including GNU C Library 2.7 or later.
  • Mac OS X 10.5.8 or the later version with the Intel chip.

The second thing you will need is the android application development tools. Here are those tools or software’s that you will need to develop android applications:

  • Java JDK 5 or later version
  • Android Studio

Both of these tools are available for free and you can download them from the web. Don’t worry, we have provided their setup process in the next sections.

Set-up Java Development Kit (JDK)

Download and install the Java Development Kit (JDK) according to your operating system version and requirement..

Here are the steps to download Java Development Kit (JDK):

Step 1 – First click on Java SE Downloads link and you will be redirected to the Oracle’s Java site.

Step 2 – Now look for the latest version of Java Development Kit and click on “JDK Download” link and you will be taken to the download page.

Step 3 – Here you have to select your OS and click on the download link after it.

Step 4 – Check on “I reviewed and accept the Oracle Technology Network License Agreement for Oracle Java SE” and click on the download link to begin. If you are using Windows OS, the “.exe” file will be downloaded.

Step 5 – Open the “.exe” file that you have downloaded and follow the instructions to install JDK on your computer.

Set-up PATH Environmental Variable

Set PATH and JAVA_HOME environment variables to refer to the directory that contains java and javac, typically java_install_dir/bin and java_install_dir respectively.

If you are using Windows OS and you have installed the Java Development Kit (JDK) in C:\jdk-15.0.2, then you need to put the following code in your C:\autoexec.bat file:

set PATH=C:\jdk-15.0.2\bin;%PATH%

set JAVA_HOME=C:\jdk-15.0.2

You can also update the PATH value by following the below steps:

Step 1 – Go to Control Panel and then to System.

Step 2 – Click on Advanced and then click on Environment Variables.

Step 3 – Add the location of the bin folder of the JDK installation to the PATH variable in System Variables.

Here is a typical value for the PATH variable:

C:\WINDOWS\system32;C:\WINDOWS;”C:\Program Files\Java\jdk-15\bin”

If you are using Linux OS and the Software Development Kit (SDK) is installed in /usr/local/jdk-15.0.2 and you use the C shell, then put the following code into your .cshrc file:

setenv PATH /usr/local/jdk-15.0.2/bin:$PATH

setenv JAVA_HOME /usr/local/jdk-15.0.2

You can also use Android Studio, then it will automatically know where you have installed your JDK.

Android Studio

There are many software’s and tools that are available for android application development. But the most popular and easy to use software is Android Studio. You can follow the below steps to download the latest version of Android Studio:

Step 1 – Go to Android Studio downloads page.

Step 2 – If you are a Windows user, then you can see the download button at the top of downloads page. You can click Download Android Studio button to begin you download.

Note – If you are a Mac, Linux or Chrome OS user, then you can simply scroll down the downloads page and you will find the links to download Android studio. Click on that link and your download will begin.

Step 3 – Check “I have read and agree with the above terms and conditions” and click on the download button.

Step 4 – For windows users, if you have download the .exe file, then you can simply click on it and follow the installation instructions. But if you have downloaded the .zip file, then first you have to extract it, copy the android-studio folder into your Program Files folder, and then open the android-studio > bin folder and launch studio64.exe (for 64-bit machines) or studio.exe (for 32-bit machines).

Android Architecture

Android OS is divided into five sections and four main layers as shown in the diagram below:

Linux Kernel

Linux Kernel is the base of the Android platform. This layer contains all the important and essential hardware drivers like Camera, Keypad, Wi-Fi, Audio, Display, etc. It handles networking & device drivers to connect to the peripheral hardware.

Hardware Abstraction Layer (HAL)

The Hardware Abstraction Layer (HAL) serves as an abstraction layer between a hardware and its software. It comprises of various library modules which implements an interface for a particular kind of hardware component, for example, the camera or Bluetooth module.

Libraries

On top of Linux Kernel there are libraries which are useful for storage and sharing of application data, libraries which are used for playing and recording audio and video, SSL libraries which are responsible for Internet security etc.

Android Libraries

  • android.app – It provides access to the application model and is the foundation of all Android applications.
  • android.content – It encourages content access, distributing and informing among applications and application segments.
  • android.database – It is used to access data published by content providers and includes SQLite database management classes.
  • android.opengl − A Java interface to the OpenGL ES 3D graphics rendering API.
  • android.os – This android library provides applications with admittance to standard working framework administrations including messages, system services and inter-process communication.
  • android.text – It is used to display, render and manipulate text on a device screen.
  • android.view – This is the fundamental building blocks of application UIs.
  • android.widget – This is a collection of pre-built components such as buttons, list views, labels, radio buttons, layout managers, etc.
  • android.webkit – This android library is a set of classes that allows web-browsing capabilities to be built into applications.

Android Runtime

This layer of the android architecture provides the key component which is Dalvik Virtual Machine. Dalvik Virtual Machine is like a Java Virtual Machine which is designed and optimized for Android.

This machine uses the core features of Linux like multi-threading and memory management, which is intrinsic in the Java language. This machine enables all the android applications to run their own process, with their own instance of the Dalvik Virtual Machine.

The Android runtime likewise gives a bunch of center libraries which empower Android application engineers to compose Android applications utilizing standard Java programming language.

Application Framework

The Application Framework layer offers numerous more elevated level types of services to applications as Java classes. Application engineers are permitted to utilize these administrations in their applications.

The Android structure incorporates the accompanying key administrations − 

  • Activity Manager – It controls all parts of the application lifecycle and activity stack. 
  • Content Providers – It allows applications to distribute and impart information to different applications.
  • Resource Manager – It provides admittance to non-code embedded resources like strings, shading settings and UI designs.
  • Notifications Manager – It allows applications to show cautions and notices to the client. 
  • View System – It is an extensible arrangement of perspectives used to make application UIs.

Android Applications

At the top layer of the android architecture you will find all the Android applications. You will compose your application to be installed on this layer. These applications are Contacts Books, Browser, Games and so on.

Android Application Components

Android Applications consists of various Application Components which are the major building blocks. These components are interconnected by the application manifest file AndroidManifest.xml.

Following are the major components of an Android Application:

1. Activities

This component describes all the activities and the user interaction with the mobile phone. This is how an activity is implemented as a subclass of Activity class:

public class MainActivity extends Activity {

}

2. Services

This component handles the background processing of an Android Application. A service can be implemented as a subclass of Service class:

public class MyService extends Service {

}

3. Broadcast Receivers

This component is an interconnection between the Android OS and applications. A broadcast receiver can be implemented as a subclass of BroadcastReceiver class and each message is broadcaster as an Intent object.

public class MyReceiver  extends  BroadcastReceiver {

   public void onReceive(context,intent){}

}

4. Content Providers

A content provider component handles and supplies the data that may be stored in a file or any other location. This component can be implemented as a subclass of ContentProvider class:

public class MyContentProvider extends  ContentProvider {

   public void onCreate(){}

}

Additional Components

There are some additional components as well that are used to construct the above mentioned entities, their logic, and wiring between them. Following are these components:

  • Fragments – It represents a portion of UI in an activity.
  • Intents – Intents is an inter application message passing framework that can be used to start and stop Activities and Services.
  • Views – UI components that are drawn on-screen including buttons, lists forms and so on.
  • Layouts – View hierarchies that control screen format and appearance of the views.
  • Manifest – It is the configuration file for the application.
  • Resources – External elements, such as strings, constants and drawable pictures.

Check out python for android app development and further your learning today!

Android Application Example

Now let’s start coding and create a simple android application using Android SDK (Software Development Kit). 

Hope that you have set-up your Android development environment properly as explained in Android – Environment Set-up tutorial.

So, let’s start creating a simple android application which will display “Hello World!”

Creating an Android Project

You have to follow the below mentioned steps to create a new Android project with Android Studio:

Step 1 – Download and install the latest version of Android Studio.

Step 2 – When you start the Android Studio you will see a Welcome to Android Studio window. In that window click Start a new Android Studio project.

If you already have a project opened, then just select File > New > New Project.

Step 3 – In the Select a Project Template window you have to select Empty Activity and then click Next.

Step 4 – Now you have to configure your project in the Configure your project window by following the below steps:

  • In the name field, enter My First App.
  • In the Package name field enter com.example.myfirstapp
  • You can also change the location of the project by changing the Save location.
  • From the Language drop-down menu select either Java or Kotlin.
  • Select the lowest version of Android your app will support in the Minimum SDK field.
  • If your app will require legacy library support, mark the Use legacy android.support libraries checkbox.
  • Leave the other options as they are.

Step 5 – Click on Finish.

Anatomy of Android Application

You need to be aware of a few directories and files in the Android project before you start running your app:

1. Java – It contains .java source files for your android application project. It includes MainActivity.java source file by default, which have an activity class that runs when the app is launched using the app icon.

2. res/drawable-hdpi – This is a catalog for drawable objects that are intended for high-density screens. 

3. res/layout – This is a directory which consists of the files that are used to define your app’s UI.

4. res/values – This directory is for other various XML files that contain a collection of resources, such as strings and colours definitions.

5. AndroidManifest.xml – This manifest file is used to describe the fundamental characteristics of the app and define each of its components.

6. Build.gradle – This is an auto generated file which contains compileSdkVersion, buildToolsVersion, applicationId, minSdkVersion, targetSdkVersion, versionCode and versionName.

The Main Activity File

MainActivity.java is a Java file is the actual application file which gets converted into a Dalvik executable and runs your android application. Below is the generated code:

package com.example.helloworld;

import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

   @Override

   protected void onCreate(Bundle savedInstanceState) {

      super.onCreate(savedInstanceState);

      setContentView(R.layout.activity_main);

   }

onCreate() method is one of the methods that is figured when an activity is loaded. R.layout.activity_main refers to the activity_main.xml file which is located in the res/layout folder.

The Manifest File

All the components you develop as a part of your application is declared in a manifest.xml which nests at the root of the application project directory. This is an interface between Android OS and your application. A default manifest file will look like as following file –

<?xml version=”1.0″ encoding=”utf-8″?>

<manifest xmlns:android=”http://schemas.android.com/apk/res/android”

    package=”com.example.tutorialspoint7.myapplication”>

   <application

      android:allowBackup=”true”

      android:icon=”@mipmap/ic_launcher”

      android:label=”@string/app_name”

      android:supportsRtl=”true”

      android:theme=”@style/AppTheme”>

      <activity android:name=”.MainActivity”>

         <intent-filter>

            <action android:name=”android.intent.action.MAIN” />

            <category android:name=”android.intent.category.LAUNCHER” />

         </intent-filter>

      </activity>

   </application>

</manifest>

Here <application>…</application> tags enclosed the components related to the application. Attribute android:icon will point to the application icon which is available under res/drawable-hdpi. The application uses the image named ic_launcher.png located in the drawable folders.

The <activity> tag is used to specify an activity and android:name attribute specifies the fully qualified class name of the Activity subclass and the android:label attributes specifies a string to use as the label for the activity. You can specify multiple activities using <activity> tags.

The activity for the purpose channel is named android.intent.action.MAIN as it is utilized to show that this action fills in as the passage point for the application. The class for the expectation channel is named android.intent.category.LAUNCHER to show that the application can be dispatched from the gadget’s launcher symbol.

The @string refers to the strings.xml file which is explained below. Hence, @string/app_name refers to the app_name string defined in the strings.xml file, which is “HelloWorld”. Similarly, other strings get populated in the application.

Following is the list of tags which you will use in your manifest file to indicate different Android application parts −

  • <activity> elements for activities
  • <service> elements for services
  • <receiver> elements for broadcast receivers
  • <provider> elements for content providers

The Strings File

The strings.xml file is located in the res/values folder and it contains all the text that are used by your application. For example, the names of buttons, default text, labels, and similar types of strings go into this file. A default strings file will look like −

<resources>

   <string name=”app_name”>HelloWorld</string>

   <string name=”hello_world”>Hello world!</string>

   <string name=”menu_settings”>Settings</string>

   <string name=”title_activity_main”>MainActivity</string>

</resources>

The Layout File

The activity_main.xml is a layout file available in res/layout directory that is referenced by your application when building its interface. You will edit and update this file frequently to change the layout of your android application. For your “Hello World!” application, this file will have following content related to default layout −

<RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android”

   xmlns:tools=”http://schemas.android.com/tools”

   android:layout_width=”match_parent”

   android:layout_height=”match_parent” >

   <TextView

      android:layout_width=”wrap_content”

      android:layout_height=”wrap_content”

      android:layout_centerHorizontal=”true”

      android:layout_centerVertical=”true”

      android:padding=”@dimen/padding_medium”

      android:text=”@string/hello_world”

      tools:context=”.MainActivity” />

</RelativeLayout>

The TextView is an Android control used to construct the GUI and it have different attribute like android:layout_width, android:layout_height and so on which are being utilized to set its width and height and so on. The @string alludes to the strings.xml record situated in the res/values organizer. Thus, @string/hello_world alludes to the welcome string characterized in the strings.xml document, which is “Hello World!”.

Running the Application

Now we will run our Hello World! application. You can either run your application on a real device or on an emulator.

Run Your Application on a Real Device

Follow the steps to run your android application on a real device:

Step1 – Connect your device using USB cable with the computer or the device on which you have developed your android app.

Step 2 – Enable USB debugging in the Developer options:

  1. Open Settings.
  2. Now, select System, then About Phone and at the bottom tap Build Number seven times.
  3. Now return to the previous screen, scroll down and tap Developer options.
  4. In the Developer options, scroll down to find and enable USB debugging.

Step 3 – Now go to Android Studio, select your application from the run/debug configurations drop-down menu in the toolbar.

Step 4 – Now select the device on which you have to run your application from the target device drop-down menu.

Step 5 – Now click Run and the android studio will install the app on your device.

Run Your Application on an Emulator

To run your application on an emulator, you have to follow the below steps:

Step 1 – In Android Studio you have to create an Android Virtual Device (AVD) that the emulator can use to install and run your app.

Step 2 – Select your application from the run/debug configurations drop-down menu in the toolbar.

Step 4 – Now select the Android Virtual Device (AVD) on which you have to run your application from the target device drop-down menu.

Step 5 – Now click Run and the Android Studio will install the app on the AVD and it will display the Emulator window.

So, now you have developed your first Android application. Congratulations!!

This was a complete tutorial of Android Application development. Now just keep practicing and following the above tutorial to become an expert in Android application development.

Remember each and every point mentioned in this tutorial. If you miss any of the point you may face some kind of an issue or it might not run. So, carefully follow all the instructions.

For a more detailed understanding of related subjects visit Great Learning Academy, where you will find various free courses.

All the best and have a Great Learning!!

Avatar photo
Great Learning Team
Great Learning's Blog covers the latest developments and innovations in technology that can be leveraged to build rewarding careers. You'll find career guides, tech tutorials and industry news to keep yourself updated with the fast-changing world of tech and business.

Leave a Comment

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

Recommended AI Courses

MIT No Code AI and Machine Learning Program

Learn Artificial Intelligence & Machine Learning from University of Texas. Get a completion certificate and grow your professional career.

4.70 ★ (4,175 Ratings)

Course Duration : 12 Weeks

AI and ML Program from UT Austin

Enroll in the PG Program in AI and Machine Learning from University of Texas McCombs. Earn PG Certificate and and unlock new opportunities

4.73 ★ (1,402 Ratings)

Course Duration : 7 months

Scroll to Top