Android Summary PDF
Android Summary PDF
Android is an opensource operating system is Linux based and is suitable for touch screen mobile
devices. Android Inc. was a small startup company founded in Lapo Alto, California in October 2003 by
ANDY RUBIN, RICH MINER, NICK SEARS and CHRIS WHITE. Then Google acquired Android Inc.
in July 2005. Android uses Linux kernels under the hood that are wrapped by a Dalvik Virtual Machine
to applications written in JAVA.
1) Installation links
Download Java Installation Tutorial
Java Installation Link
Download Android Studio Installation Tutorial
Android Studio Installation Link
2) Folder Structure
While developing in Android, we will primarily code in two languages, XML and Java.
XML: This is used to create static content. This includes views, variable values and styles.
Java: The app logic is written in Java files. These can be in the form of Activities, Services, etc. We will
see these in more detail in the coming tutorials.
The XML files have a .xml extension and Java files have .java extension. The output file that we host on
Google Play/ transfer to Android phone has a .apk extension.
External Libraries: This is the place where all the referenced libraries and the information about the
targeted platform SDK are stored.
3) java Folder
This directory and all its sub directories hold the .java files. These files dictate the logic of the app.
This is how the java folder looks for a typical app.
4) res Folder
Resources are the additional files and static content that your code uses, such as bitmaps, layout
definitions, user interface strings, animation instructions, and more. The res folder contains these
resources in the following directories-
Sub-directories of res folder
anim/: For XML files that are compiled into animation objects.
color/: For XML files that describe colors.
drawable/:For image files (PNG, JPEG, or GIF), 9-Patch image files, and XML files that
describe Drawable shapes or Drawable objects that contain multiple states (normal, pressed, or
focused).
mipmap/: For app launcher icons. This folder contains additional sub-folders for different
screen resolutions. Once an image is imported into this folder, Studio automatically resizes the
image into different resolutions and places them in the appropirate folders. This behavior allows
launcher apps to pick the best resolution icon for your app to display on the home screen. To see
how to import an image into the mipmap folder, please read about using 'Image asset'.
layout/: XML files that are compiled into screen layouts (or parts of a parent layout).
menu/: For XML files that define application menus.
values/: For XML files that define constants that can be accessed in other XML and Java files.
R.java
R.java is an uneditable file auto-generated by Studio, whenever we modify the XML content. This file
links the XML values to Java files. Whenever we need to use XML values in a Java file, we call these
values using the R class.
The following images show a sample XML file, where a string variable named 'title' is assigned a value
of 'Internshala - Tic Tac Toe'. This variable is then accessed in a java file using the R class.
5) Building Blocks
An Android app is built using the following components
Manifest: This file declares the app components, user permissions, app name, launcher icon etc.
Activities: An activity represents a single screen with user interface.
Services: A service is a component that runs in the background to perform long-running
operations. A service does not have a user interface
Content Providers: A content provider allows us to access a shared set of application data (for
example, contacts, music, videos etc.)
Broadcast Receivers: A broadcast receiver is a component that responds to system-wide
broadcast announcements (for example, incoming/outgoing calls/ SMSs etc.)
In this workshop, we will only cover Manifest, activities and services. You are encouraged to read all the
above components in detail after the workshop.
6) Android Manifest
The manifest file presents essential information about your app to the Android system. The system must
have this information before it can run any of the app's code.
The main functions of the manifest are:
All activities, services etc. must be declared in the Manifest.
7) Activities
An activity is a screen of the application with a user interface. Whenever you run an application, the first
thing you come across is a screen which is an activity. Activity provides the space for drawing UI
components with which user interacts with an app.
For example, when you run the HelloWorld app, the first screen which displays 'Hello World' is an
activity. An app must have at least one activity. When you open an app, the first activity that opens is
called the launcher activity or main activity. An application can also have multiple activities. As we have
seen before, all activities need to be specified in the manifest.xml. The launcher/main activity must be
declared with additional information.
However, it is no longer visible to the user so its window is hidden and it will often be killed by the
system when memory is needed elsewhere.
If an activity is paused or stopped, the system can drop the activity from memory by either asking it to
finish, or simply killing its process. In this case, when it is displayed again to the user, it must be
completely restarted and restored to its previous state.
To stop, a service can call stopSelf() method to stop itself or another service can stop it by
calling stopService().
9) Intents & Intent Filters
Intents are used to start a new activity. They are like messengers that carry certain data about the activity
that is to be started. Intents can also be used to start a new service or to deliver a broadcast.
The following code shows how to start the activity using explicit intent.
We have defined a filter which will capture 'http' requests. Here action defines that we want
to view something, category is default (i.e we are not defining it to particular category eg. Launcher,
Home, etc.) and in data we are adding a check to capture all required 'http' requests.
We are creating an intent with Action as Intent.ACTION_VIEW and we are passing a http uri. After
that, we are starting ImplicitActivity just by passing the above intent to startActivity() method. Since
this intent contains the same action (Intent.ACTION_VIEW) & data (http uri), so automatically our
Intent-Filter captures this and starts ImplicitActivity.
12.1) Java
Android is based on Java to a large extent. You should know opbject-oriented programming concepts
such as classes, objects, inheritance etc. You should also know basics such as input/output, variables,
loops etc. You should also be able to read and undertand documentation to learn how to use new parts of
the Java SDK.
12.2) The Android SDK
It includes:
Different types of layouts & views
Activities, Intents & Services
Fragments
Lifecycle of an activity
Interacting with web
Material Design
Integration with various APIs
Action Bar
Android has had several versions (Cupcake, Donut, Eclair, Froyo, Gingerbread, Honeycomb, Ice Cream
Sandwich, Jelly Bean, KitKat, Lollipop, Marshmallow). A developer must ensure that the APIs and
features work with the required versions.
Android devices have many different screen sizes, resolutions and pixel densities. A developer must
ensure that the app works on all of them.