MOBILE APPLICATION DEVELOPMENT
CHAPTER 1
INTRODUCTION
Android has long occupied the dominant position in the mobile operating system market. As of
June 2019, there are more than 2.7 million available apps in the Google Play Store. In recent years,
computation power and memory size of smart phones are inter-procedural static analysis methodology to
detect the misuse patterns of Asynchronous Task. Due to this single-GUI-thread model, it is vital to avoid
blocking the UI thread. Therefore, most GUI frameworks recommend offloading intensive tasks (e.g.,
network access, database queries) to Asynchronous threads (i.e., background threads). Take Android
development framework (ADF) as an example, it provides many async programming constructs (e.g.,
AysncTask, Thread, AsyncTaskLoader, IntentService) to achieve this goal.
1.1 INTRODUCTION TO ANDROID
The Android operating system is most frequently used on different mobile platforms around the
world. It is occupied approximately 75% of shares in the worldwide market by the end of 2020. A
company like Open Handset Alliance has developed the first Android that depends on the customized
version of the Linux kernel as well as other open-source software. At the initial stage of 2005, Google
sponsored the project & it obtained the entire company. In September 2008, the first Android device was
released in the market to dominate the mobile industries due to several features like user friendly, the
support of the community is huge, customization, manufacturing of android devices in large companies.
Consequently, the market examines the demand to develop Android-supported devices with smart
developers. So, the Android operating system became a complete set of operating systems for different
devices like wearables, mobiles, notebooks, smart TVs, tablets, set-top boxes, etc.
1.2 INTRODUCTION TO PROJECT
When an application is launched, Android activates a thread, which is called main thread or UI
thread, to run the application. If the main thread executes CPU-blocking or IO-blocking tasks, then
theapplication will be blocked, which may lead to a problem known as Application Not Responding
(ANR). To avoid unresponsiveness, time-consuming tasks need to be executed in background [Link]
order to ease asynchronous programming, Android provides AsyncTask, an encapsulation of the
concurrency framework. With the help of AsyncTask, developers can perform background operationsand
publish results on the UI thread without direct threads manipulation.
Dept of CSE, GECT 2021-2022 Page 1
MOBILE APPLICATION DEVELOPMENT
CHAPTER 2
LITERATURE SURVEY
Google. 2018. Processes and Threads. Retrieved 2018-7 f since Android UI toolkit is not thread-
safe, the single-GUI-thread model requires that async threads should not directly manipulate GUI objects.
GUI objects include visible components (e.g., update a Dialog’s message) and data models (e.g., change
the content of Array Adapter that fits in between a List View and an Array List) [5]. Instead, they should
designate the UI thread to handle GUI objects via UI-safe methods like Activity#runOnUiThread. In
asynchronous programming, the main thread only accounts for the UI update while time-consuming and
CPU (IO)-blocking tasks are encapsulated into background threads [1].
Google. 2018. Processes and Threads. Retrieved 2018-7 f in order to simplify asynchronous
programming, Android provides several packaged asynchronous components such as AsyncTask and
Intent Service. Among them, AsyncTask is easy to implement and thus widely used by Android
developers [5]. However, many developers still choose AsyncTask as their first choice because of its
convenience [1].
Cong Zheng, Shixiong Zhu, Shuaifu Dai, Guofei Gu, Xiaorui Gong, Xinhui Han, and Wei Zou.
2012. SmartDroid: An Automatic System for Revealing UI-based Trigger Conditions in Android
Applications. In Proceedings of the Second ACM Workshop on Security and Privacy in Smartphones and
Mobile Devices (SPSM ’12). ACM, New York, NY, USA, 93–104. Guided Test Generation Our work
uses static analysis to locate suspicious APEs, and then guides GUI interactions to verify them [4]. This
idea is also adopted in other application domains of Android. Smart Droid [2].
Linjie Pan, Baoquan Cui, Jiwei Yan, Xutong Ma, Jun Yan, and Jian Zhang. 2019. Androlic: an
extensible flow, context, object, field, and path-sensitive static analysis framework for Android [4]. In
Proceedings of the 28th ACM SIGSOFT International Symposium on Software Testing and Analysis,
ISSTA 2019, Beijing, China, July 15-19, 2019. 394–[Link] have implemented the approach of misuse
detection on AsyncTask into a tool named AsyncChecker. It is written in Java based on Androlic, a flow,
context, object, field-sensitive static analysis framework [4]. As figure 2 shows, AsyncChecker generates
the class hierarchy relation and dummy main method for subsequent analysis. We can analyze the
semantics of statements via the core engine of Androlic. In accordance with the misuse detection of
AsyncTask, we implement some APIs of Androlic [3].
Dept of CSE, GECT 2021-2022 Page 2
MOBILE APPLICATION DEVELOPMENT
CHAPTER 3
REQUIREMENT SPECIFICATION
In this chapter we will see what the basic requirements of the project are. A requirement specification
is a collection of all requirements that are to be imposed on the design and verification of the product. The
specification also contains other related information necessary for the design, verification, and maintenance of
the product.
3.1 HARDWARE REQUIREMENTS
Processor : INTEL i3, i5, i7, i9 10th Gen or Above
Ram Hard Disk : 8GB RAM (primary memory) DDR4
Minimum : 128GB Storage capacity (secondary memory) SSD or Above
Output Device : Monitor (1920x1080) Display Resolution
Input Device : Mouse, Keyboard.
3.2 SOFTWARE REQUIREMENTS
Operating System : Windows 10 or above
IDE : Android IDE
Programming Language : Java, xml
Compiler : Android Emulator S (Android12)
Dept of CSE, GECT 2021-2022 Page 3
MOBILE APPLICATION DEVELOPMENT
CHAPTER 4
SYSTEM DESIGN AND ANALYSIS
In this chapter we define the design of a system functionalities and flow diagram of an application
and also the class diagram of asynchronous android application.
4.1 FLOW DIAGRAM
Figure 4.1: Asynchronous Task Flow Diagram
As Shown in above figure 4.1 an asynchronous task is defined by a computation that runs on a
background thread and whose result is published on the UI thread. An asynchronous task is defined by 3
generic types, called Params, Progress and Result, and 4 steps, called onPreExecute, doInBackground ,
onProgressUpdate and onPostExecute .
Dept of CSE, GECT 2021-2022 Page 4
MOBILE APPLICATION DEVELOPMENT
4.2 CLASS DIAGRAM
Figure 4.2 Class Diagram of Asynchronous Task in Android
In the above figure 4.2 shows the string, void and integer data types
String is used to tell that the input data is of type String.
Void is used to tell that we do not want to publish the progress on the main UI thread.
Integer is used to tell that the result will be in the form of an Integer.
Why AsyncTask…?
If our app deals with the data loading from the internet or over a network or doing any other task which
can take time and you are using the main thread to execute the operations of that task then it introduces a
lot of loads on the main UI thread.
Why should AsyncTask be used ideally for small operations…?
As you may have seen that 3 methods in AsyncTask run on the main UI thread and only two(including the
publishProgress( ) method run on the background thread. This type of working can block the main UI
thread even though the task to be performed is being done in the background.
Dept of CSE, GECT 2021-2022 Page 5
MOBILE APPLICATION DEVELOPMENT
CHAPTER 5
SYSTEM IMPLEMENTATION
In this chapter we implement the android application. The information of android studio and the
architecture of android studio is defined thoroughly
5.1 ANDROID STUDIO
Android that was announced in May 2013 at the Google I/O developer’s event, and is intended as
an alternative to Eclipse. Android Studio is based on the Java IDE called IntelliJ. If you’ve worked with
other products by JetBrains (developer of IntelliJ), such as RedMine,PyCharm, PhpStorm, WebStorm, or
AppCode, you will find yourself at home. All IntelliJ products share the same shell IDE, which you’ll see
as soon as you open up Android Studio.
Android Studio is a brand-new IDE, it is important to note that most of your IDE skills from
Eclipse apply to Android Studio as well. Most of the tooling in Android Studio is ver similar to Eclipse,
such as shortcuts, designers, and code editors. You’ll still export signed APKs, view logcat, and edit code
virtually the same way in Android Studio as if you were in Eclipse. Think of Android Studio like this: if
Eclipse were a trusty old power drill used in construction, Android Studio is the new cordless high-
powered version of that same drill. Android Studio has some of the same options, and some new ones that
you’ll need to familiarize yourself with. In the end, you’ll still feel comfortable enough to use the tool to
get the desired result—an Android app.
5.2 ANDROID DEVELOPMENT ARCHITECTURE
Figure 5.2: Android Development Architecture
Dept of CSE, GECT 2021-2022 Page 6
MOBILE APPLICATION DEVELOPMENT
As shows in the above figure 5.2 Android Development Architecture, where it shows how the
complete architecture of the android is formed and how it is designed. For the development of the android
application the [Link], [Link], [Link], res, [Link] are the mainly
used.
5.3 SYSTEM ARCHITECTURE DIAGRAM
Figure5.3: System Architecture
The above figure 5.3 system architecture diagram clearly shows the architecture of the Project.
Using the User Interface, the user of the application interacts with the programmed business logic. The
business gets the data from the database which is JAVA program in this application. This Interacts and
gives the data to the programmed logic and the information is processed and displayed back on the user
interface.
Dept of CSE, GECT 2021-2022 Page 7
MOBILE APPLICATION DEVELOPMENT
CHAPTER 6
ADVANTAGES AND DISADVANTAGES
In this chapter we discuss the advantages and disadvantages of the Asynchronous task android
application
6.1 ADVANTAGES
Provides generic solution for all network calls
Publish progress to UI while executing.
Run Asynchronously
Easy to maintain and read.
Process controllability
Clear structure and clear functional definition
Simple and clear for multiple background tasks
6.2 DISADVANTAGES
The main disadvantage of using an AsyncTask and why they should rarely be used…
Block the main UI thread → One reason for this is the same as mentioned above that it can block
the UI thread thereby freezing the app.
Wastage of memory →The creation of another AsyncTask can not only happen through refresh
button but a rather more general and practical example is suppose an AsyncTask is already running
and the user rotates the screen, then another Activity will created and the former activity will go to
the Stopped State and since there is a completely new Activity a new AsyncTask is created and a new
background thread is created and then suppose the user again rotates the screen before the task is
completed, then another AsyncTask is created with a new background thread, and it can happen again
and again creating multiple number of AsyncTasks in the memory thereby creating a large number of
AsyncTask objects is created in the memory which in turn, wastes a lot of memory and since memory
is a very precious resource in Android and should be used as efficiently as possible, it is not at all
recommended. And if this scenario happens again & again than Android OS will have no choice but
to forcefully destroy your Activity which you definitely do not want to happen.
Can lead to Memory Leaks → If the user rotates the screen another AsyncTask is created and as
you know that the previous AsyncTask did not finish executing. Now, after the 1st AsyncTask
Dept of CSE, GECT 2021-2022 Page 8
MOBILE APPLICATION DEVELOPMENT
completes with the 2nd Activity in the foreground then that AsyncTask will try to return the result to
the onPostExecute() method of an Activity which does not exist and hence it leads to memory leaks.
6.2.1 MISUSE OF ASYNCTASK
Figure 6.2.1: Misuse of AsyncTask
The above Figure 6.2.1 shows an overview of our approach to statically analyze AsyncTask-related
misuse patterns. There are three steps in our approach:
Preprocessing: The input is an apk file. During preprocessing, we first obtain its class hierarchy
relation through APIs provided by Soot. Then we unify lifecycle callback methods and user-
defined callback methods into a dummy main method for each Activity just as FlowDroid does.
Static Analysis: After preprocessing, we perform flow, context, object and field-sensitive inter
procedural static analysis to collect type state, reference and loop information about
Detection: At last, we detect whether usage of AsyncTask is correct via predefined detection rules
based on the collected information during static analysis. Any code segments containing
AsyncTask misuse will be recorded in bug reports.
Dept of CSE, GECT 2021-2022 Page 9
MOBILE APPLICATION DEVELOPMENT
CHAPTER 7
RESULTS
This chapter defines the figures of our asynchronous task android project in details every figure
has different information of our project
Figure 7.1: Home Page
This figure 7.1 shows the initial home page of our android project asynchronous task where one
text view and 2 buttons are displayed on the screen.
Figure 7.2: Start Task
In the above Figure 7.2 the asynchronous task will run in the background by clicking on the start
button which is displayed on the screen. For the user confirmation the popup message will be displayed.
Dept of CSE, GECT 2021-2022 Page 10
MOBILE APPLICATION DEVELOPMENT
Figure 7.3: End Task
The above Figure 7.3 describes stopping of the asynchronous task by clicking on the END button
which is displayed on the screen.
Dept of CSE, GECT 2021-2022 Page 11