Chapter 1-Introduction To Android Platform

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

COLTECH

Computer Engineering

Mobile Application Development

DJIONGO Cedrigue
djiongocedrigue@gmail.com

© 2020
University of Bamenda / College of Technology
Computer Engineering
Master 1
Academic Year: 2019-2020

Syllabus:
Mobile Application Development
Code and Course Title: Mobile Application Development
Credits: 3
Hour charge: 30h (CM = 20; TD /TP= 5; TI = 5)
Teacher: DJIONGO KENFACK Cedrigue Boris, +237 697121054,
djiongocedrigue@gmail.com
Availability: End of the week / August, September, May
Assistant (chargé de TD / TP) :
Prerequisite:
Keywords : mobile apps, constrained resources, sensors, security, Android, Google
Play Store
Software : Visual Studio Code, Android SDK
Objectives :
This course introduces students to programming technologies, design and development
related to mobile applications. Topics include accessing device capabilities, industry standards,
operating systems and programming for mobile applications using OS Software Development
Kit (SDK). This project oriented course will investigate application development for the
Android mobile Platform. We will look at the techniques for building applications that adapt to
the ways in which mobile apps differ from traditional desktop ar web-based apps, including
constrained resources, small screen sizes, varying display resolutions, intermittent network
connectivity, specialized sensors and security restrictions.
Upon completion, students should be able to:
(1) Create basic applications for mobile devices, debug and test a mobile application,
(2) Apply layout management and multi-layout definition techniques to create adaptable user
interfaces for mobile applications that share a common data model, (3) Manage user data and
multimedia on a mobile device via the Android framework libraries, (4) Use the sensors
available on mobile devices to enhance user interaction and feedback, and (5) Publish
application to the Google Play Store.

1 / 19
Bibliography :
[Späth2018] Peter Späth, Pro Android with Kotlin: Developing Modern Mobile Apps,
ISBN: 978-1-4842-3820-2, Apress, 2018
[Wickham2018] Mark Wickham, Practical Android: 14 Complete Projects on
Advanced Techniques and Approaches, ISBN: 978-1-4842-3333-7, Apress, 2018
[Jackson2017] Wallace Jackson Android Apps for Absolute Beginners: Covering
Android 7, 4th Ed. ISBN:978-1-4842-2268-3, Apress, 2017
[DiMarzio2017] J. F. DiMarzio, Beginning Android® Programming with Android
Studio, ISBN: 978-1-119-19609-9, John Wiley & Sons, 2017

2 / 19
Chapter 1 Introduction to Android Platform
The Android OS was originally created by Andy Rubin to be an OS for mobile phones.
It was born as the child of the Android Inc. company in 2003 and was later acquired by Google
LLC in 2005 as part of its strategy to enter the mobile space. Google wanted the Android OS
to be open and free, so most of the Android code was released under the open source Apache
License. Moreover, vendors (typically hardware manufacturers) can add their own proprietary
extensions to Android and customize Android to differentiate their products from others.
However, the Nexus devices always run a clean version of Android with no modifications.

The first device running Android came on the market in 2008. Since then it has had
numerous updates, with the latest version number at the beginning of 2018 reading 8.1. Ever
since its first build, the market share of the Android OS has been constantly increasing, and by
2018 it is said to be greater than 80 percent. The Android OS is tailor to match the needs of
smartphones and other handheld or handheld-like devices. Android devices come in all shapes
and sizes including, but not limited to, the following types of devices: Smartphones, Tablets,
E-reader devices, Internet TVs, Automobiles, and Smartwatches.

The main advantage to adopting Android is that it offers a unified approach to


application development. Developers need only develop for Android in general, and their
applications should be able to run on numerous different devices, as long as the devices are
powered using Android. In the world of smartphones, applications are the most important part
of the success chain.

1.1 Android Operating System


The Android ecosystem is made up of a combination of three components: (1) A free,
open source operating system for embedded devices, (2) An open source development platform
for creating applications, and (3) Devices that run the Android operating system (and the
applications created for it). More specifically, Android is made up of several necessary and
dependent parts, including the following:

 A Compatibility Definition Document (CDD) and Compatibility Test Suite (CTS) that
describe the capabilities required for a device to support the Android software stack.
 A Linux operating system kernel that provides a low-level interface with the hardware,
memory management, and process control, all optimized for mobile and embedded
devices.

3 / 19
 Open source libraries for application development, including SQLite, WebKit,
OpenGL, and a media manager.
 A run time used to execute and host Android applications, including the Android Run
Time (ART) and the core libraries that provide Android-specific functionality. The run
time is designed to be small and efficient for use on embedded devices.
 An application framework that agnostically exposes system services to the application
layer, including the Window Manager and Location Manager, databases, telephony, and
sensors.
 A user interface framework used to host and launch applications.
 A set of core preinstalled applications.
 A software development kit (SDK) used to create applications, including the related
tools, IDE, sample code, and documentation.

Android provides you, as a developer, with the opportunity to create applications


designed to look, feel, and function exactly as you imagine them using Kotlin, Java, or C++ as
a programming language, or a combination of them. The Android OS contains the power of a
complete computer OS. It is based on the Linux Kernel open source platform, and Oracle Java
Standard Edition, one of the world’s most popular programming languages.

1.1.1 Android features


Because Android is open source and freely available to manufacturers for
customization, there are no fixed hardware or software configurations. However, the base
Android OS supports many features, including:

 Storage: SQLite, a lightweight relational database, for data storage.


 Connectivity: GSM/EDGE, IDEN, CDMA, EV-DO, UMTS, Bluetooth (includes
A2DP and AVRCP), Wi-Fi, LTE, and WiMAX.
 Messaging: Both SMS and MMS.
 Media support: H.263, H.264 (in 3GP or MP4 container), MPEG-4 SP, AMR, AMR-
WB (in 3GP container), AAC, HE-AAC (in MP4 or 3GP container), MP3, MIDI, Ogg
Vorbis, WAV, JPEG, PNG, GIF, and BMP.
 Hardware support: Accelerometer sensor, camera, digital compass, proximity sensor,
and GPS.
 Multi-touch: Multi-touch screens.
 Multi-tasking: Multi-tasking applications.
 Tethering: Sharing of Internet connections as a wired/wireless hotspot.

4 / 19
Android’s web browser is based on the open source WebKit and Chrome’s V8
JavaScript engine.

1.1.2 Android Architecture


Android is a mobile operating system based on a specially tailored Linux kernel. This
kernel provides all the low-level drivers needed to address the hardware, the program execution
environment, and low-level communication channels. On top of the kernel you will find the
Android Runtime (ART) and a couple of low-level libraries written in C. The latter serve as a
glue between application-related libraries and the kernel. The Android Runtime is the execution
engine where Android programs run. Above the low-level libraries and the Android Runtime
sits the application framework, which defines the outer structure of any app you build for
Android. It deals with activities, GUI widgets, notifications, resources, and so on. While
understanding the low-level libraries certainly helps you to write good programs, knowing the
application framework is essential to writing any Android app at all. On top of all that you will
find the apps your users launch for tasks they have to accomplish. The Android OS is roughly
divided into five sections in four main layers as shown by Figure 1:

1. Linux kernel: This is the kernel on which Android is based. This layer contains all the
low-level device drivers for the various hardware components of an Android device.
2. Libraries: These contain the code that provides the main features of an Android OS.
For example, the SQLite library provides database support so that an application can
use it for data storage. The WebKit library provides functionalities for web browsing.
3. Android runtime: The Android runtime is located in the same layer with the libraries
and provides a set of core libraries that enable developers to write Android apps using
the Java programming language. The Android runtime also includes the Dalvik virtual
machine, which enables every Android application to run in its own process, with its
own instance of the Dalvik virtual machine. (Android applications are compiled into
Dalvik executables). Dalvik is a specialized virtual machine designed specifically for
Android and optimized for battery-powered mobile devices with limited memory and
CPU power.
4. Application framework: The application framework exposes the various capabilities
of the Android OS to application developers so that they can make use of them in their
applications.
5. Applications: At this top layer are the applications that ship with the Android device
(such as Phone, Contacts, Browser, and so on), as well as applications that you

5 / 19
download and install from the Google Play Store. Any applications that you write are
located at this layer.

Figure 1: Android Architecture.

1.2 Android development system


Android applications normally are written using the Java or Kotlin programming
languages, and are executed by means of the Android Run Time (ART). Each Android
application runs in a separate process, relinquishing all responsibility for memory and process
management to the Android Run Time, which stops and kills processes as necessary to manage
resources. ART sits on top of a Linux kernel that handles low-level hardware interaction,
including drivers and memory management, while a set of APIs provides access to all the
underlying services, features, and hardware.

6 / 19
1.2.1 Integrated Development Environment
The first and most important piece of software you need to download is Android Studio.
After you have downloaded and installed Android Studio, you can use the SDK Manager to
download and install multiple versions of the Android SDK. Having multiple versions of the
SDK available enables you to write programs that target different devices. For example, you
can write one version of an application that specifically targets the latest Android OS under
development, but because that flavor of Android is on less than 1% of devices, with multiple
versions of the SDK you can also write a version of your app that uses older features and targets
older Android OS. You can download Android Studio from:

http://developer.android.com/sdk/index.html

1.2.2 Android SDK


The software development kit (SDK) is a loosely coupled selection of tools that are
essential for Android development. They can all be started from within a shell and come with
or without their own GUI. The Android SDK contains all of the packages and tools required to
develop a functional Android application. The SDKs are named after the version of Android
OS to which they correspond. By default, the latest stable SDK release is install with Android
Studio. However, if you want to install a different Android SDK, you can do so using the SDK
Manager from the Android Studio welcome screen.

The Android SDK includes everything you need to start developing, testing, and
debugging Android applications:

 The Android API Libraries: The core of the SDK is the Android API libraries that
provide developer access to the Android stack. These are the same libraries that Google
uses to create native Android applications.
 Development tools: The SDK includes the Android Studio IDE and several other
development tools that let you compile and debug your applications to turn Android
source code into executable applications.
 The Android Virtual Device Manager and Emulator: The Android Emulator is a
fully interactive mobile device emulator featuring several alternative skins. The
Emulator runs within an Android Virtual Device (AVD) that simulates a device
hardware configuration. Using the Emulator you can see how your applications will
look and behave on a real Android device. All Android applications run within ART, so

7 / 19
the software emulator is an excellent development environment, in fact, because it’s
hardware-neutral, it provides a better independent test environment than any single
hardware implementation.
 Full documentation: The SDK includes extensive code-level reference information
detailing exactly what’s included in each package and class and how to use them.
 Sample code: The Android SDK includes a selection of sample applications that
demonstrate some of the possibilities available with Android, as well as simple
programs that highlight how to use individual API features.
 Online support: Android has vibrant developer communities on most online social
networks, Slack, and many developer forums. Many Android engineers from Google
are active on Stack Overflow and Twitter.

You also need to download and install the Java SDK compatible with your Android
Studio.

1.2.3 Android Virtual Devices


An Android Virtual Device (AVD) is an emulator instance that enables you to model
an actual device. Each AVD consists of a hardware profile; a mapping to a system image; and
emulated storage, such as a secure digital (SD) card. One important thing to remember about
emulators is that they are not perfect. There are some applications, such as games (which are
GPU heavy) or applications that use sensors such as the GPS or accelerometer that cannot be
simulated with the same speed or consistency within an emulator as they can when running on
an actual device. However, the emulator is good for doing some generalized testing of your
applications. You can create as many AVDs as you want to test your applications with different
configurations. This testing is important to confirm the behavior of your application when it is
run on different devices with varying capabilities.

The Emulator enables you to see how your application will look, behave, and interact,
but to actually see what’s happening under the surface, you need the Android Profiler. The
Android Profiler displays real-time profiling data for the CPU, memory, and network activity
related to your app. You can perform sample-based method tracing to time your code execution,
capture heap dumps, view memory allocations, and inspect the details of network-transmitted
files. The Profiler window displays real-time graphs for CPU, memory, and network usage, as
well as an event timeline that indicates changes in Activity state, user inputs, and screen
rotations.

8 / 19
1.2.4 Android Debug Bridge
The Android Debug Bridge (ADB) is a client-service application that lets you connect
with an Android device (virtual or actual). It’s made up of three components:

 A daemon running on the device or Emulator


 A service that runs on your development computer
 Client applications that communicate with the daemon through the service
As a communications conduit between your development hardware and the Android device/
Emulator, the ADB lets you install applications, push and pull files, and run shell commands
on the target device. Using the device shell, you can change logging settings and query or
modify SQLite databases available on the device. Android Studio automates and simplifies a
lot of your usual interaction with the ADB, including application installation and updating, file
logging, and debugging.

1.2.5 Gradle
Gradle is an advanced build system and toolkit, which makes it possible for you to
perform custom build configurations without needing to modify your app’s source files. The
use of Gradle as Android’s build system is intended to make it easier to configure, extend and
customize the build process, simplify code and resource reuse, and to more easily create
multiple build variants of an application.

The output of the build is the same whether you are building a project from the command line,
on a remote machine, or using an IDE.

1.3 Using XML


We present in this section how Android’s XML capabilities allow application
developers, and application designers, to define their Android application user interface design,
styles, themes, constants, permissions, icons, activities, services, and how they function within
the Google Play e-storefront.

1.3.1 Extensible Markup Language: XML Overview


XML stands for eXtensible Markup Language. Markup languages differ from
programming languages, in that they use tags, parameters (also called attributes or
characteristics) within these tags, and nesting structures to accomplish tasks that high-level
programming languages will implement using complex programming structures like data

9 / 19
arrays, logic loops, and method calls. XML markup is contained in simple text format files
identified using the .xml file extension.

Some examples of advanced Android design-related features that you can implement
primarily using XML markup “definitions” include multi-state graphics, skinned UI elements
(custom graphic design User Interface elements), frame or bitmap image animation, vector or
“tween” (procedural) animation, user interface layout design animation (UI property animator),
options menus, pop-up menus, and context-sensitive menus, dialog boxes, alert dialogs, styles,
themes, and your application’s manifest. You can also implement less advanced, strategic
design features using XML, including string (text) constant values for your app, integer
(numeric) value constants, state or status (Boolean) value constants, and screen spacing
(dimension) values for your UI designs. Arrays, which are collections of data used in your app
(like a simple database), can also be created, and loaded with their data values, by using XML
files.

1.3.2 XML Naming Schema: Tag and Parameter


Repository
XML is comprised of “tags” and their “parameters.” Parameters are part of the tags,
and are used to configure and fine-tune what each of these tags accomplishes, as well as to
reference any new media assets, or styles, or themes, or otherwise define how that application
user interface element will appear, or “render,” relative to your users’ Android device display
screen.

XML tags and parameters that you can use in any particular design framework are
specified by using an XML “naming schema.” This definition of the XML tags and their
parameters are stored in a centralized repository. The SDK repository hosts the latest Android
SDK versions and code base, whereas the Android XML repository is located at a different
URL location (a different folder) on Google’s Android OS servers. The reason XML needs to
have a naming schema is because this language is inherently designed to be “extensible.” The
process of making sure that XML tags and their attributes or parameters are correct, or valid
and in conformance with their XML definition, is called XML validation.

Android XML has been specifically customized for, and implemented for, the
development of Android applications. Android Studio does not need to validate the XML file
in “real time”, so you do not need an active Internet connection to be able to develop the XML
markup. The following lines of XML markup declare XML and the XML naming schema,

10 / 19
abbreviated as XMLNS, as well as configuring the ConstraintLayout Java class characteristics
using attributes or parameters inside of the parent <ConstraintLayout> tag.

This parent layout container tag will usually contain other child tags, which are nested
inside of, and underneath, the opening parent tag. This nesting of child tags, as well as nesting
parameters inside of the tag, can more easily seen if the XML programmer uses indenting to
show which tags are inside of other higher-level (parent) tags.

1.3.3 XML Syntax: Containers, Brackets, and Nesting


There are two ways to code any XML tag, and which markup approach you use depends
upon whether that tag is going to have any children or not. Attributes or parameters, are inside
of each tag and configure the tag and what it will do. Parameters will use quotation marks to do
this, such as android:text="data value". If an XML tag is a parent tag, it can be said to be a
container, just like the XML file itself is the container for that entire XML construct, which
Android uses for data or Java object definition of one type or another.

Any tag that you will use as a parent tag will have an opening tag; in this case that is the
<ConstraintLayout> tag, and its paired closing tag </ConstraintLayout> with the tag name in
both the opening and the closing tag. The closing tag will have a slash in front of the tag name
to signify to the XML parsing engine (the code that is interpreting the XML markup and turning
it into Java objects, data constants, and data variables) that this is the closing tag. Alternatively,
the child tag that has no children of its own will have the closing slash at the end of the opening
tag. Once you put parameters inside of the parent and child tags, and indent everything, so that
you know what level each of these tags and its parameters are supposed to be ( see code below).

11 / 19
1.3.4 XML Referencing: Chain XML Constructs
Together
XML files can also reference other XML files, so that you can create a chain where
XML definitions can be modular, since they can be blocks of code that can be used by more
than one XML construct. XML file referencing is somewhat akin to XML tag nesting, but it
spans across files. XML referencing in Android is done by using an @ symbol, which is specific
to Android XML file referencing syntax.

Android uses the @ character to signify that another XML file is being referenced to
define values, dimensions, strings, styles, themes, and your Android Manifest, which defines
everything regarding your application. Without this referencing capability XML markup would
end up being all lumped together in one or two massive files. Referencing allows an XML
structure to be created.

1.3.5 XML Styles: Editing Styles or Themes Using XML


Android styles and the Android OS themes they reference are a collection of style
definitions Styles and themes are called “materials”. In short, what a style does is allow you to
define, in one central location, how the UI design of your application is going to look, as far as
color, spacing, and font characteristics (text typeface, type, and size) are concerned. This
approach allows you to extract the styling of your UI design from the actual content within that
design, and from the programming logic behind how that UI design functions.

12 / 19
1.4 Programming with Java
The programming language used for developing your Android applications is Oracle’s
Java SE, which was created by Sun Microsystems and later acquired by Oracle. Java SE stands
for Java Standard Edition, though many programmers shorten this to just “Java.” Java is what
is called an object-oriented programming (OOP) language.

OOP is based on the programming concept of developing modular, self-contained


constructs that are called objects. These OOP constructs can contain their own attributes and
characteristics. In this section we will present briefly the OOP characteristics of Java, the Java
programming language constructs, like packages and classes, methods and interfaces, loops and
arrays, variables and constants, and application programming interfaces (APIs). Together these
Java constructs will allow you to create the application’s objects and then modify them
according to the programming logic that the application will utilize. This creates a user
experience for your end users.

1.4.1 A Foundation of OOP Constructs: An Object


The foundation of OOP is the object itself. Everything you create in Java is an object
and uses other objects (and data primitive values). Objects in OOP languages are similar to the
objects that you see around you every day, except Java objects are virtual, and are not tangible.
Just like tangible real-world objects, Java objects have characteristics, called states or
attributes, and things that they do, called behaviors. One way to think about this distinction is
that Java objects are nouns, or things that exist in and of themselves, whereas their behaviors
are like verbs, or things that these nouns can do.

1.4.2 Java Programming Terms


We present some of the technical terminology used in Java. First, objects have data
fields to hold variable data, constants to hold fixed data, and methods to define behaviors, as
follows:

 Data fields that hold a Java object’s states that can change over time are called
variables.
 Data fields that hold an object’s states that do not change over time are called constants.
 Methods are programming logic or program code routines that operate on, and will
change, the object’s internal variable data fields. Methods will also allow other Java
objects that are external to the object itself to communicate with that object, as long as
the method is declared to be public.

13 / 19
One of the key concepts of OOP is data encapsulation. In Java, data encapsulation is
implemented by only allowing a Java object’s variable data fields to be modified directly
through that same Java object’s internal methods. This allows a Java object to be self-sufficient,
or encapsulated. Using data encapsulation, you can individually build and test each object that
is part of a larger object construct, without requiring any data to be accessed from other objects,
or modules, of an application. External data access can translate into bugs, so encapsulation
helps when developing complicated, large-scale applications. Its also promotes the core
concept in OOP of modularity. Once an object is created and tested, other objects can use it
without worrying about its integrity. Data encapsulation thus allows code reuse, so
programmers can develop libraries of useful objects, which don’t need to be rewritten or
retested by other programmers. Finally, Java objects make debugging easier, because you can
add or remove them modularly, or isolate them during testing in order to ascertain where bugs
are located within the overall code.

1.4.3 Java Constructs


a- Java Class
In Java SE, you write something called a class that defines what your object can do (its
methods), and what data fields it will possess. Once the class has been coded in Java, you can
then create an instance of an object that you wish to use, by referencing a class definition. An
instance is a concrete object created from the blueprint of the class, with its own states or unique
data attributes. In architectural terms, the class is a kind of blueprint as to what the object will
be structured like, including what states it will contain, its other attributes (constants), and the
tasks it can perform (the methods that it has).

To create a class, you use the Java keyword class, followed by a custom name for the
new class you are writing, and then curly brackets, which will eventually contain Java code for
a class definition. For a car class, it looks like this:

The first thing that you will usually put inside of the class (inside of the curly {}
brackets) are the data fields (variables).

To define a variable in Java, you must first declare its data type:

 An integer or int data type declares a variable to be able to hold a whole (non-fractional)
number.

14 / 19
 A String data type declares the variable to hold a text value.
 A Boolean data type declares the variable to hold a true or false value (I think of this
like a switch or a toggle, like a binary on or off state).

The next portion of the variable definition or declaration after the data type has been
specified is your custom variable name, which you will use to refer to that variable later on,
within your Java programming logic. The variable definition is ended once it reaches a
semicolon character.

b- Java Method
A Java method will define how your object will function; that is, how it will operate
on the variables that you defined at the top of the class. Method calls can invoke a variable
(state) change, and methods can also return data values to the entity that calls or invokes the
method, such as data values that have been successfully changed, or even the result of an
equation.

c- Construct method
If you want to be able to make an object with preset values out of your class definition,
then you need to include what is called a constructor method. If you don’t, Java will create
one for you called a default constructor. This method will need to be named the same as the
class name, and should be the first method that is defined inside of the class construct, after the
data field definitions. The constructor method is used to construct an object, configure it, and
load it into memory for use. If all objects that are created using the class need to have the same
starting variables, you can include these in the class instead of the constructor.

The Java constructor method differs from a regular Java method in a number of distinct
ways. First of all, a constructor method does not use any of the data return types, such as
void and int, because it is used to create a Java object, rather than to perform some function. It
does not return nothing or a number, but rather, it returns an object. Another difference between
a constructor and a standard method is constructors must use the public access control modifier,
and cannot use any non-access-control modifiers, so be sure not to declare your constructor as:
static, final, abstract, or synchronized.

d- Java Inheritance
There is also support in Java for developing different variations on custom objects. This
is done using a technique called inheritance. Inheritance is where more specialized classes can
be subclassed using the basic superclass. This allows Java developers to develop more

15 / 19
organized, modular, inheritance-oriented approaches to designing their Java objects, making
them into building blocks, and thus powerful for the construction of an infinite number of future
object types.

To create a subclass using a superclass, you extend the subclass from the superclass, by
using the Java extends keyword inside of the class declaration. To refer to one of the
superclass’s methods from within the subclass you are coding, you can use the Java super
keyword.

e- Java Interfaces
In many Java applications, Java classes must conform to a certain usage pattern. There
is a specialized Java construct called an interface that you can implement, so that other
application developers will know exactly how to utilize your Java classes implementing an
interface, as well as which methods are required for proper implementation of your Java class.
Implementing the Java interface will allow your class to become more conformant regarding
those behaviors that your class offers for other programmers to utilize.

To implement a Java interface, you would use the Java implements keyword, as you
will see later on during this section. Interfaces in essence form a programming contract
between your class and the rest of the development world. For any class implementing a Java
interface, the Java compiler can enforce this contract at build time. If a class claims to
implement a public interface using the implements keyword, all of the methods that are defined
by that Java interface definition must be implemented in the source code for the class that
implements that interface before that class will successfully compile.

f- Logical Collection of Classes


The Java package declaration is the first line of code in any Android application class,
or in any Java class in any application for that matter. The package declaration tells Java how
to package your application. After the package keyword and declaration come the import
statements, which import existing Java classes and packages into your declared package.

Basically, a Java package naming strategy is similar to the folder-naming hierarchy on


your computer. A package is just a way of organizing (grouping) Java code according to
functionality. As an example, Android organizes its classes into over 100 logical packages,
which we will routinely import, and use, throughout this book. Each Android API Level
contains a vast collection of functional packages that are utilized by developers to access the
Android OS feature set.

16 / 19
g- Java Access Modifiers: Four Levels of Access
Java has a number of modifiers that you can place before Java constructs, to define what
they are and who can see them. There are two types of Java modifiers: access control modifiers
and non-access control modifiers. You can apply access control modifiers to classes, methods,
interfaces, constructors, constants, and variables, and include the public, private, and protected
Java access modifier keywords. Not using any access control keyword at all also defines the
package protected level of access control.

There are also modifiers in Java that are not access control modifiers, and not data type
declarations. These are called non-access modifiers and these are the most complicated ones
to understand and to implement in practical usage. There are three modifiers that are frequently
used in Java programming: a static modifier, a final modifier, and an abstract modifier. There
are also some more advanced modifiers such as synchronized or volatile.

A static modifier keyword when used in conjunction with a variable will create a
variable that will exist independently of any object instances created using that class. Static
variables will be initialized only one time, at the start of the execution of the application,
sometimes called the app launch. The variables that use the static modifier keyword will be
initialized first, before the initialization of any instance variables. Only one copy of a static
variable will exist in system memory regardless of the number of instances of the class that
contains that variable are created.

You can define a class using the final modifier keyword, and if a class is designated
final, it cannot be subclassed. This is usually implemented for reasons of Java security, so
tested, mission-critical Java code cannot be modified or changed. You will notice as we get
deeper into the Android API and Java that many standard Android Java-based library classes
are declared using the final modifier keyword. All methods in a final class are implicitly final
methods. Any method declared using the final modifier keyword cannot be overridden by
subclasses.

17 / 19
A class declared using an abstract modifier keyword can never be instantiated, or
placed into memory as an object and actually utilized in the functionality of an Android (or
Java/ JavaFX) application. If your class is declared as abstract, then the sole purpose for that
class is to be extended, that is, subclassed. If a class contains any methods that have been
declared using the abstract modifier, then the class should also be declared using the abstract
modifier.

1.5 Case Study: an earthquake viewer application


In this course, we will create an app that will use a feed of earthquake data from the
United States Geological Survey (USGS) to display a list and a map of recent earthquakes.

The students should be organized in groups of 4 members each and will propose an
Android Application to be develop though the course. Each group is ask to identify a problem
in their environment and propose an Android app to handle this issue.

We will use Visual Studio Code with Android extensions and tools as the alternative to
Android Studio IDE.

1.6 Exercises
1. What is an AVD?
2. Why was Jelly Bean selected for you by default in the Targeted Android Devices dialog?
3. What does SDK stand for?
4. What tool is used to download new Android SDKs?
5. As an exercise, you should practice identifying different objects in the room or space around
you, and then break down their definition or description into various states as well as
behaviors

18 / 19
19 / 19

You might also like