You are on page 1of 11

ASYNCHRONOUS TASK 2020-2021

CHAPTER 1
INTRODUCTION
1.1 Overview

Mobile app development is rapidly growing. From retail, telecommunications and e-


commerce to insurance, healthcare and government, organizations across industries must meet
user expectations for real-time, convenient ways to conduct transactions and access information.
So, for our project Asynchronous task, we’ll be focusing on moving a banner from left to right.

1.2 Problem Statement


To develop an application to demonstrate the use of Asynchronous tasks in android. The
asynchronous task should implement the functionality of a simple moving banner. On pressing
the Start Task button, the banner message should scroll from right to left. On pressing the Stop
Task button, the banner message should stop.

1.3 The Solution

AsyncTask was intended to enable proper and easy use of the UI thread. However, the
most common use case was for integrating into UI, and that would cause Context leaks, missed
callbacks, or crashes on configuration changes.

1.4 Proposed system


AsyncTask’s primary goal is to make it easy to run a Thread in the background that can
later interact with the UI thread. Therefore, the most common use case is to have an AsyncTask
run a time-consuming operation that updates a portion of the UI when it’s completed.

Dept of ISE, MIT Mysore


Page 1
ASYNCHRONOUS TASK 2020-2021

CHAPTER 2

SOFTWARE REQUIREMENT SPECIFICATIONS


2.1 System Requirements

2.1.1 Hardware Requirements:

PROCESSOR: Pentium 3 and higher (1.2GHZ and higher)


RAM : 4GB and higher
HARD DISK: 20GB

2.1.2 Software Requirements:

Operating system: Windows XP/7.


Coding Language: XML, Java
Software Required: Android Studio
2.1.3 Functional Requirements:
An Asynchronous call does not block the program from the code execution. When the
call returns from the event, the call returns back to the callback function. So, in the context of
Java, we have to create a new thread and invoke the callback method inside that thread.
AsyncTask must be subclassed to be used. The subclass will override at least one method, and
most often will override a second one.

In this project we are using asynchronous task to display the toast message travelling
right to left.

2.1.4 Non-Functional Requirements:


The purpose of this project is to display the message travelling from right to left. When
we press start button the message should be travelled from right to left. When we press stop
button the displaying message should be stopped.

Dept of ISE, MIT Mysore


Page 2
ASYNCHRONOUS TASK 2020-2021

AsyncTask class is firstly executed using execute () method. In the first step
AsyncTask is called onPreExecute () then onPreExecute () calls doInBackground ()
for background processes and then doInBackground () calls onPostExecute () method to
update the UI.

2.2 Software description

XML (eXtensible Markup Language):


Android layouts are written in eXtensible Markup Language, also known as XML.
Much like HTML (or Hypertext Markup Language), XML is also a markup language. It was
created as a standard way to encode data in internet-based applications. However, unlike HTML,
XML is case-sensitive, requires each tag is closed properly, and preserves whitespace.

Much like creating an HTML layout and later altering it with jQuery, as we've done in previous
courses, we can create XML layouts in Android, and later alter them using Java logic.

Android XML layouts are also part of a larger umbrella of Android files and components called
resources. Resources are the additional files and static content an application needs, such as
animations, colour schemes, layouts, menu layouts.

JAVA:
Java is a class-based, object-oriented programming language and is designed to have as
few implementation dependencies as possible. A general-purpose programming language made
for developers to write once run anywhere that is compiled java code can run on all platforms
that support java.
Java applications are complied to byte code that can run on any Java Virtual Machine.
The syntax of Java is similar to C/C++.

Dept of ISE, MIT Mysore


Page 3
ASYNCHRONOUS TASK 2020-2021

Android Studio:
Android Studio is the official Integrated Development Environment (IDE) for Android app
development, based on IntelliJ IDEA. On top of IntelliJ's powerful code editor and developer
tools, Android Studio offers even more features that enhance your productivity when building
Android apps, such as:

• A flexible Gradle-based build system

• A fast and feature-rich emulator

• A unified environment where you can develop for all Android devices

Dept of ISE, MIT Mysore


Page 4
ASYNCHRONOUS TASK 2020-2021

CHAPTER 3
IMPLEMENTATION

3.1 Introduction to Mobile Application Development:

Android is an operating system and programming platform developed by Google for


smartphones and other mobile devices (such as tablets). It can run on many different devices
from many different manufacturers. Android includes a software development kit for writing
original code and assembling software modules to create apps for Android users. It also provides
a marketplace to distribute apps. All together Android represents an ecosystem for mobile apps.

Apps are developed for a variety of reasons: addressing business requirements, building
new services, creating new businesses, and providing games and other types of content for users.
Developers choose to develop for Android in order to reach the majority of mobile device users.

Android is designed to provide immediate response to user input. Besides a fluid touch
interface, the vibration capabilities of an Android device can provide haptic feedback. Internal
hardware such as accelerometers, gyroscopes and proximity sensors, are used by many apps to
respond to additional user actions. These sensors can detect rotation of the screen from portrait to
landscape for a wider view or it can allow the user to steer a virtual vehicle in a racing game by
rotating the device as if it were a steering wheel.

The Android platform, based on the Linux kernel, is designed primarily for touchscreen
mobile devices such as smartphones and tablets. Since Android devices are usually battery-
powered, Android is designed to manage processes to keep power consumption at a minimum,
providing longer battery use.

Dept of ISE, MIT Mysore


Page 5
ASYNCHRONOUS TASK 2020-2021

3.2 Android Architecture


Android provides a rich development architecture. The following diagram shows the
major components of the Android stack — the operating system and development architecture.

System Apps User Apps


1

Java API Framework


2

Native C/C++ Libraries Android Runtime


3

Hardware Abstraction Layer (HAL) 4

Linux Kernal 5
Figure: Android Architecture

In the figure above:


1. Apps: Your apps live at this level, along with core system apps for email, SMS messaging,
calendars, Internet 1.0: Introduction to Android 8 browsing, or contacts.
2. Java API Framework: All features of Android are available to developers through application
programming interfaces (APIs) written in the Java language. You don't need to know the details

Dept of ISE, MIT Mysore


Page 6
ASYNCHRONOUS TASK 2020-2021

of all of the APIs to learn how to develop Android apps, but you can learn more about the
following APIs, which are useful for creating apps: View System used to build an app's UI,
including lists, buttons, and menus. Resource Manager used to access to non-code resources such
as localized strings, graphics, and layout files. Notification Manager used to display custom
alerts in the status bar. Activity Manager that manages the lifecycle of apps.
3. Libraries and Android Runtime: Each app runs in its own process and with its own instance of
the Android Runtime, which enables multiple virtual machines on low-memory devices. Android
also includes a set of core runtime libraries that provide most of the functionality of the Java
programming language, including some Java 8 language features that the Java API framework
uses. Many core Android system components and services are built from native code that require
native libraries written in C and C++. These native libraries are available to apps through the
Java API framework.
4. Hardware Abstraction Layer (HAL): This layer provides standard interfaces that expose
device hardware capabilities to the higher-level Java API framework. The HAL consists of
multiple library modules, each of which implements an interface for a specific type of hardware
component, such as the camera or bluetooth module.
5. Linux Kernel: The foundation of the Android platform is the Linux kernel. The above layers
rely on the Linux kernel for underlying functionalities such as threading and low-level memory
management. Using a Linux kernel enables Android to take advantage of key security features
and allows device manufacturers to develop hardware drivers for a well-known kernel.

3.3 Asynchronous Task


Use the AsyncTask class to implement an asynchronous, long-running task on a worker
thread. (A worker thread is any thread which is not the main or UI thread.) AsyncTask allows
you to perform background operations and publish results on the UI thread without manipulating
threads or handlers. When AsyncTask is executed, it goes through four steps:
1. onPreExecute () is invoked on the UI thread before the task is executed. This step is normally
used to set up the task, for instance by showing a progress bar in the UI.

Dept of ISE, MIT Mysore


Page 7
ASYNCHRONOUS TASK 2020-2021

2. doInBackground (Params...) is invoked on the background thread immediately after


onPreExecute () finishes. This step performs a background computation, returns a result, and
passes the result to onPostExecute (). The doInBackground () method can also call
publishProgress (Progress...) to publish one or more units of progress.

3. onProgressUpdate (Progress...) runs on the UI thread after publishProgress (Progress...) is


invoked. Use onProgressUpdate () to report any form of progress to the UI thread while the
background computation is executing. For instance, you can use it to pass the data to animate a
progress bar or show logs in a text field. 4. onPostExecute (Result) runs on the UI thread after
the background computation has finished.

Dept of ISE, MIT Mysore


Page 8
ASYNCHRONOUS TASK 2020-2021

CHAPTER 4
SNAPSHOTS

Snapshots of Asynchronous Task on Emulator

Dept of ISE, MIT Mysore


Page 9
ASYNCHRONOUS TASK 2020-2021

CONCLUSION

This application allows us to run the instruction in the background and then synchronize
again with our main thread. It is used to do background operations that will update the user
interface. This application code runs in our main thread and every statement is therefore execute
in a sequence. Here first we are going to fetch some data from API (Web service) and display it
in our user interface.
In the future this application can be increased the speed of the background operations so
that it can update the user interface as soon as possible.

Dept of ISE, MIT Mysore


Page 10
ASYNCHRONOUS TASK 2020-2021

REFERENCES

➢ https://www.tutorialspoint.com/android-asynctask-example-and-explanation
➢ https://google-developer-training.github.io/android-developer-fundamentals-course-
concepts/en/android-developer-fundamentals-course-concepts-en.pdf

➢ https://distancelearning.louisiana.edu/teach-remotely/asynchronous-teaching-tips
➢ Headfirst Android Development: A Brain-Friendly Guide 1st Edition

➢ Android Programming for Beginners

Dept of ISE, MIT Mysore


Page 11

You might also like