VIETNAM NATIONAL UNIVERSITY HCM UNIVERSITY OE INFORMATION TECHNOLOGYFACULTY OF INFORMATION SYSTEM BUI QUANG ANH GRADUATE THESIS BUILDING A BLOOD DONATION APPLICATION BACHELOR OF ENGINEER
Trang 1VIETNAM NATIONAL UNIVERSITY HCM UNIVERSITY OE INFORMATION TECHNOLOGY
FACULTY OF INFORMATION SYSTEM
BUI QUANG ANH
GRADUATE THESIS
BUILDING A BLOOD DONATION
APPLICATION
BACHELOR OF ENGINEERING IN INFORMATION SYSTEMS
HO CHI MINH CITY, 2023
Trang 2VIETNAM NATIONAL UNIVERSITY HCM UNIVERSITY OE INFORMATION TECHNOLOGY
FACULTY OF INFORMATION SYSTEM
BUI QUANG ANH - 18520441
HO CHI MINH CITY, 2023
Trang 3INFORMATION ON THE GRADUATE THESIS BOARD
Graduation thesis grading committee, established under Decision No.
" bbeteeeeeeeeeeeeeee ees dated of the Rector of the University of
1 - Chairman.
PA ôốỐỐ - Secretary.
E - Member
Trang 4The thesis topic of building a blood donation application on the mobile platform is
the content that I researched and made my graduation thesis after studying at the
Faculty of Information Systems, University of Information Systems, University of Information Technology - Vietnam National University Ho Chi Minh City While researching and completing the thesis, I received a lot of attention and support from teachers, colleagues, family, and friends For the successful completion of this
thesis, I would like to express my sincere thanks to:
Faculty of Information Systems, University of Information Technology - Vietnam National University, Ho Chi Minh City has created a very good learning and
training environment, providing me with useful knowledge and skills to help me
apply and improve my skills advantages in writing the thesis.
Instructor PhD Do Trong Hop is a teacher who wholeheartedly guided and helped
me throughout researching and writing this thesis He gave me some ideas and
suggestions to help me complete this research.
I would also like to thank the Board of Directors and teachers at the University of
Information Technology for allowing me to study and work at the university to gain practical knowledge and experience I have helpful information for my thesis.
Finally, I would like to thank my family and friends for always encouraging me and creating the best conditions for me to strive to complete my research project well Sincerely thank!
Trang 5UNIVERSITY OF INFORMATION TECHNOLOGY
ADVANCED PROGRAM AEF
IN INFORMATION SYSTEMS
Advanced Education
Program
OUTLINE DETAILS
THESIS TITLE: BUILDING A BLOOD DONATION APPLICATION
Advisor: Do Trong Hop (Ph.D.)
Ta Thu Thuy (MSc.) Duration: From August 2022 to January 2023
Student: Bui Quang Anh - 18520441
Contents:
1 Overview
e@ Blood donation is a vital part of worldwide healthcare It allows for blood
transfusion as a life-sustaining and life-saving procedure Over one hundred million units of blood are donated each year throughout the world This
activity reviews donor eligibility and selection, adverse effects of donation, and pathogen reduction and inactivation for donated blood This activity highlights the role of the interprofessional team in ensuring appropriate protocol is followed.
e@ With a rapid increase in the usage of social network sites across the world,
there is also a steady increase in blood donation requests as is noticed in the number of posts on these sites such as Facebook and Twitter seeking blood donors Finding blood donors is a challenging issue in almost every country There are some blood donor finder applications in the market such as the
Blood app by Red Cross and the Blood Donor Finder application by
Neologix However, more reliable applications that meet the needs of users are prompted.
Trang 6e Pre-donation information is linked to the process of donor selection in which
everyone’s suitability to donate is carefully assessed against a set of criteria (2,18) [1] related to their medical history and risk for TTI This is followed
by a basic health check to:
- Ascertain that they are healthy, suitable to give blood, and will not
be harmed by blood donation.
- Avoid collecting blood from individuals who may be unsuitable due
to the risk of TTI or other health factors that may harm patients.
e The main reason for building a blood donation application was to help create
an application that can help improve the efficiency of the blood donor
selection and blood collection process by adding the step of confirming information after the user fills in This application includes 3 main
- Create a convenient and secure exchange environment Meet the
needs of blood donors or recipients of blood from users.
- Research- related technologies.
- Design UI/UX for App.
- Build App based on documents.
- Test ona real mobile phone
Research timelines:
1 Implementation plan:
Work description Time
Research topic: Aug 10, 2022 — Aug 15, 2022 (5 days)
Trang 7Aug 16, 2022 — Aug 26, 2022(10 days)
Build App: (Code) Aug 27, 2022 — Dec 20, 2022(115 days)
Test products Dec 21,2022 — Dec 28,2022(7 days)
Write report Nov 28,2022 — Dec 28,2022(30 days)
Approved by the advisor(s) Ho Chi Minh City, / / Signature(s) of advisor(s) Signature(s) of student(s)
Trang 8Table of contents
Chapter 1 Problem Statement cece esseseseseseeseseeeseeessessseersssesesesneeneees 8
1.2 TÑ€ASON LH HH HH TH HH HH HH HH HH 8 1.3 TPPUTDOSG eseeeseeecscecseseseesacscecscsesesesasecseseseseseseessseesssseeeseeaeeceeaeee 9
1.4 Subject and scope of the Study cc cecccseseeeeeeseseseeneeetesseessesesetenseetseaeee 9 1.4.1 Subjec(: Ă Ăn ri 9 1.4.2 Scope of the S(Udy: c- 5+ +2 S* 2x2 r Hgrườn 0 1.5 Report Structure 46⁄2 n, à.c.c.cccee.ec 0 Chapter 2 VerVIW cà HH HH 1
21 Android OS OVeTVICW, +1 tk HT T011 H00 it 2
2.1.1 IntroductiOn 6S ST HH nếp 2
2.1.2 ChanlbcrisfiESb SÀ ổP GSP, coi 3 2.1.3 Architecture Android 5+ 5+5 *‡xtsrtrteketekerrrrrererree 4 2.2 Android Studio
2.2.1 Introduction.
2.2.2 Controls in AndrOid ¿+ + Sky 21 2.3 Java Overview.
2.3.1 Introduction «+ Sàn TT HH ng rưết 25 2.3.2 Basic Features of Java
2.4 Introduction Firebase c.ccccecscsecseseescesesesneeseseseeeseseseseeeeseseeseeeneeeee 27
2.4.1 Definition
2.4.2 The services [2] c.cccccecccessesesecsesseseeseseesesesseeseseseesessesecaeeesseeeeesaeeeeee 28
Trang 92.5 E0) 1006107 32
2.5.1 DefinitiOn - - LH TH TH TH TH HH HH ệt 322.5.2 SITUCẨUT€ LH HH HH HH HH ng 33Chapter 3 Analysis and đ€SIØT1 G2 3321118211 8891113 111 11 1118 11 vn rry 37
3.1 System ANALYSIS 0.0 eee 37
CS, 0v 373.1.2 System design OV€TVI€W LH HH HH HH Hệ 383.1.3 Use Case DIagTam - cv SH HH ng 383.1.4 Use Case Sp€CIÍICAfION Ăn HT TH ng tư 393.1.5 Sequence DIagTam + cess s x1 ệt 583.2 IMirie 8314:0077 66
3.3.6 VIEW US€T DAB€ Go HH nHHệt 75
3.3.7 Profile page HH HH HH HH nh 763.3.8 Edit profile page HH HH TH HH HH HH nh như 713.3.9 Notification DAỹG HH TH HH HH 783.3.10 Make an appointment DaØC - - s1 1n ng ng rrg 79
Trang 104.2 Future Work cccccccccccccccccccccccccccsccccceeessessseseseesssssssseseesesssseseeceeeseessseeeeeeesReference
Trang 11Figure 2.8 Write data cece cece ccs HT HH HH kg 29
Figure 2.9 AuthenfICafIO - - c1 1v HH TH HH nh 30Figure 2.10 Sign-in me€thOỞ - c1 8318831118331 1 891 18 1119 1119 ve 30Figure 2.11 Cloud meSSaØ1n G1101 113101 11911 91H HH ng 31Figure 2.12 Firebase database Query cccccssccsssecesseeeseeeeseeeeeeceeeceaeessaeeeseeeeeneesaes 31Figure 2.13Java-Mail Architect cccceccccssecescceseecesceeeeeeeseeeeneeeseeeeaeessaeeesaeenseeenaes 32Figure 2.14 JavaMail in appÏICafIOT c2 11210189311 111 119 1 v.v nh re 33
Figure 2.15 Blood Donation GmaIÌL - - << + + E33 E**EE+eEEseeeeeeeeeeeesreere 33
Ia09028 Và 0/ì00.2)400)/1 0 35Figure 2.18 Make a Java mail AIPÌ - - - - 1 1211991 199111911 9v ng re 36Figure 2.19 Result of Java Mail APÌL - - s91 HH 36Figure 3.1 System ATChit€CfUT€ 6 + x3 9 TH TH ng HH Hưng giờ 37
Figure 3.2 Data ÍÏOW Là HH HH HH HH HH HH 38
Figure 3.3 Use case (1aØTATT - c3 01113111 19111 91019910 19v nh 38Figure 3.4 Login Activity DIaðTAI - - ĩc 3111919911191 1 vn ng re 41Figure 3.5 Log out Activity D1agTATm - G1111 ng ng tr 43Figure 3.6 Register Activity ÏDiaØTaIm - c c1 v1 1 vn ng ng 45Figure 3.7 Accept the request Activity DiagðTa1m sàn sseeerserske 47Figure 3.8 Edit Profile Activity DIaðTAI - 5 5 + vn ng ng gưkt 51
Trang 12Figure 3.9 View User List Activity D1aØTAIm - - c S11 vs series 53
Figure 3.10 Notification Activity Diagram eee csceseceeesseeneeeseseeeeeeeaeees 55Figure 3.11 Make an appointment Activity Diagram 0.0 eee eee c< << csseese 57Figure 3.12 Login Sequence D1agTaTm - -.- 5 5 + +3 1v nh nh ng tr 58
Figure 3.13 Log out Sequence Diagram < + v1 re 59Figure 3.14 Register Sequence ÏDiagTram -. - c 1x v1 re 60Figure 3.15 View List User Diagram - 5 + + 1xx HH HH ng rưệt 61Figure 3.16 Edit POIÏC «111 1 1 3 9 2 TH HH HH Hư Hưng nh 62Figure 3.17 Notification Sequence D1agTam - - - - s + xxx ssieseeere 63Figure 3.18 Make an appointment 4 5 5 E1 11 931 11 1 1 nh nh ng tr 64Figure 3.19 Accept Request Sequence [Diagøram - «+ + s+++kx+seexeseesesers 65Figure 3.20 Refuse Request Sequence DiagøTam - - 5+ ++< + s*++se++eexseeseeers 66Figure 3.21 Login Page 6 + St TT TH HH TH HH rệt 69
Figure 3.23 Register page 2c HH HH TH HH net 71Figure 3.24 Home page for OTIOT + E2 3E EE*EEESEESEEEESeeerseeeereeeereere 72Figure 3.25 Home page for T€CIDI€TIE - c c E2 1321018391113 1119 111 re 73Figure 3.26 Navigation VI€W DAB€ Gv 74Figure 3.27 View IIS€T -ĩ Ăn TT TT TH TH TH Hà HH HH hệt 75Figure 3.28 Profile Da4B€ - «ng TT TH TH Hà HH Hư Hưng ch gà 76Figure 3.29 Edit profile page - G2 c 1191 HH HH ng 77Figure 3.30 Notification page cccccccssccsssessseceseceseeeeseeeeeceseeceeeeeaeeeeaeceeaeceeeeeaes 78Figure 3.31 Choose the hospital to make an appoinfmen - ‹-s«+<s« 79
Figure 3.32 Choose day and time to make an appoInfImeIi «<s« 80
Figure 3.33 Confirm information ccccscccescesseceeseeeseeeeeeseeeceeeeeseeseaeeseaeensneeeaes 81
Trang 13Table catalog
9 0210) (oe Fe - - - 1111111111111 11 199 9095505551111 KKEEEng 1 kkkkEEEEE 67Table 3.2 Table Email - - - ( << < << << << 1 11111111E1E8E1 111111111111 118835555555 111k kkkkkkkeree 67Table 3.3 Table NofificatIOI - << < << << E111 SSS SE SE SE 035505111 kkkkkkkkkrer 68
Trang 14Currently, the medical issue is very focused, on the need for blood for surgery,
emergency treatment for serious patients due to injuries, traffic accidents, and
serious diseases such as cancer, and chronic kidney disease requiring dialysis Inwhich there are emergency surgeries that require several dozen units of blood Thisleads to the need for blood donation becoming a necessity However, it is difficult
to find blood donors and blood donors who know the need for blood They may not
be able to reach through media or articles, so it becomes difficult for people in need
of blood to reach blood donors or vice versa To solve the above problems, the
blood donation application is built to be a place where blood donors and people in
need of blood or hospitals can find the blood type in need in the fastest way Alongwith the rapid increase in the use of mobile applications worldwide, the blood
donation application built on the Android platform makes it possible for users to
have an application to use on their mobile devices The blood donation application
is built with features such as registering a user account with the necessary
information, displaying other user information whose group matches the blood type
of the registrant, and helping users able to donate blood Make an appointment withthe hospital to make a blood donation, receive notifications from people who want
to receive blood, and search for their desired blood type From there, the problem offinding blood becomes easier and the problem of anemia will be improved ProblemStatement
Trang 15Chapter 1 Problem Statement
12 Reason
Due to the impact of the COVID-19 epidemic, blood donation has encountered a
shortage of blood for treatment or emergency treatment for patients Anemia is
becoming a factor that needs to be overcome quickly to ensure stability in medical
problems In the urgency of ensuring blood supply for emergency and treatment, a
blood donation application was developed In the current information technology
era, mobile phones are indispensable devices for people The increasing demand forinformation exchange and the need to use high-tech products with many features,
high configuration, high quality, beautiful designs, and richness, so suppliers mustalways improve and improve their products your device products Therefore,
building applications for mobile phones is a potential new industry and promises
many great developments in the science and technology industry
Along with the development of the mobile phone, the market is strong development
the trend of application software programming for mobile devices Application
software for phones is now very diverse and popular: Android, iOS, and J2MF Afew years later, the Android operating system was born with the inheritance of
advantages of the operating systems that were born Before the combination of themost advanced technologies, the famous developer of today's technology was
Google Android quickly became a strong competitor to previous operating systemsand was the most popular
Today, with the rapid development of society, most people use smartphones, the
internet is everywhere, and Wi-Fi is everywhere, so you can access the internet andeverything you need The need to change information and communicate anytime,
anywhere is very necessary, so I chose the topic "Building a blood donation
application on Android" This application helps users to participate in blood
donation or find the right blood type quickly and safely
Trang 161.3 Purpose
Building blood donation applications on Android phones satisfied:
+ Simple, easy to use intuitive interface, easy to manipulate.
+ Suitable for widely deployed applications, the expansion is less expensive
+ The system is easy to maintain and develop
+ Make sure to meet the user’s needs.
+ Building safe and reliable applications
1.4 Subject and scope of the study
1.4.1 Subject:
The first important object in this study is the donor blood type of the donor There
are four main blood types and eight different blood types In medicine, this is called
the ABO Blood Group System The four main blood groups are A, B, O, or AB andeach type can be positive or negative, so we have 8 blood groups used to donate
blood including A+, A-, B+, B-, AB+, AB-, O+, O- Blood groups are allowed to
donate according to the chart below:
Figure 1.1 Blood donation chart
Trang 171.4.2 Scope of the study:
In this topic, the application focuses on developing search and scheduling features
for users
The scope of the study is divided into 2 users:
+ Blood donors: Provide blood donation information and respond to results when
the person in need of blood sends a request
+ Blood recipients: Search for people who are donating blood matching their bloodtype Submit a request to receive blood from a blood donor
+ Hospitals: A place where blood donors and recipients can choose to conduct
blood donation or blood exchange
1.5 Report Structure
Chapter 1: - Problem Statement: State the reason for choosing the topic, purpose,object, and scope of the research
Chapter 2: - Overview: Analyze and evaluate existing research directions of
domestic and foreign authors related to the topic; state outstanding issues; points outthe problems that the topic needs to focus on, and research to solve
Chapter 3: -Analysis and design: Presenting theoretical basis, theory, scientific
hypothesis, and research methods used in the thesis
Chapter 4: - Experimental Results: Briefly describe the scientific research work
carried out, the results of the scientific research, or the experimental results For
application topics that result in software products, there must be design, and
installation, according to learned models (UML, )
Chapter 5: - Summary and Future work: Present the results achieved, new
contributions, and new proposals The conclusion should be brief, without further
discussion and commentary
10
Trang 18Chapter 6: - References: Include materials cited, used, and mentioned for
discussion in the thesis
Chapter 2 Overview
There is now an application built related to this blood donation, which is the BloodDonor application [1] This application is an application to look up blood donor
information and blood donation locations and chat on the application of the
National Institute of Hematology - Blood Transfusion Following the development
of User-oriented Blood, Donor application is blood donors Blood Donor activities
include providing blood to hospitals, looking up hospitals, blood donation history,
grouping blood donors together, registering to donate blood online, and tracking theblood unit journey gives The application has identified the audience to use the
application and has built the application to meet the needs of the customer and builtthe application with a user-friendly interface The app's developers have determinedthat the main goal of the app is to increase the number of blood donors and thereby
provide users with what they need so that they can donate blood However, this
application is not aimed at people in need of blood because the application only
focuses on blood donation to hospitals So, the application is only used for donors
and hospitals If someone needs blood and needs to look up a blood donor, it will
not be possible through this application With the above problem, I realize that there
is still an outstanding problem to be solved that is the application needs to connect
more people in need of blood with the application to expand the ability to supply
blood from the donor to the person in need This problem of the application is veryimportant because it affects the time to receive the blood of the person in need of
blood If the time to receive blood is improved, the success rate of the patient's
emergency will be increased Therefore, the wide connection of users is a problemthat needs to be solved To solve this missing problem, a blood donation application
has been built that allows 3 participants including blood recipients, blood donors,
and hospitals
lãi
Trang 192.1 Android OS Overview [1]
2.1.1 Introduction
Android is an open-source and Linux-based Operating System for mobile devices
such as smartphones and tablet computers Android was developed by the Open
Handset Alliance, led by Google, and other companies Android offers a unified
approach to application development for mobile devices which means developers
need only develop for Android, and their applications should be able to run on
different devices powered by Android The first beta version of the Android
Software Development Kit (SDK) was released by Google in 2007 whereas the firstcommercial version, Android 1.0, was released in September 2008 On June 27,
2012, at the Google I/O conference, Google announced the next Android version,
4.1 Jellybean Jellybean is an incremental update, with the primary aim of
improving the user interface, both in terms of functionality and performance The
source code for Android is available under free and open-source software licenses.Google publishes most of the code under the Apache License version 2.0 and the
rest, Linux kernel changes, under the GNU General Public License version 2 The
android platform integrates many outstanding features:
e Beautiful UI: Android OS basic screen provides a beautiful and intuitive user
interface
e Connectivity: GSM/EDGE, IDEN, CDMA, EV-DO, UMTS, Bluetooth, Wi-Fi,
LTE, NFC, and WiMAX
e Storage: SQLite, a lightweight relational database, is used for data storage
purposes.
e Media support: H.263, H.264, MPEG-4 SP, AMR, AMR-WB, AAC, HE-AAC,
AAC 5.1, MP3, MIDI, Ogg Vorbis, WAV, JPEG, PNG, GIF, and BMP
e Messaging: SMS and MMS
e Web browser: Based on the open-source WebKit layout engine, coupled with
Chrome's V8 JavaScript engine supporting HTMLS and CSS3
12
Trang 20e Multi-touch: Android has native support for multi-touch which was initially
made available in handsets such as HTC Hero
e@ Multi-tasking: The user can jump from one task to another, and at the same time
various applications can run simultaneously
e Resizable widgets: Widgets are resizable, so users can expand them to show
more content or shrink them to save space
e Multi-Language: Supports single-direction and bi-directional text.
e GCM: Google Cloud Messaging (GCM) is a service that lets developers send
short message data to their users on Android devices, without needing a
proprietary sync solution
e Wi-Fi Direct: A technology that lets apps discover and pair directly, over a
high-bandwidth peer-to-peer connection
e Android Beam: A popular NFC-based technology that lets users instantly share,
just by touching two NFC-enabled phones together
2.1.2 Characteristics
a Open source
Android is built from the ground up allowing developers to create
compelling mobile apps that take full advantage of the strengths of existinghandsets Android is completely open, an application can call any of the corephone functions such as making calls, sending messages, or using the
camera, allowing developers to create richer, more connected features
capabilities for users Android is built on the open Linux kernel In addition,
it uses a virtual machine that has been optimized for memory and hardwarefor mobile environments Android, which is open source, it can be extended
to freely combine emerging technologies This platform will continue to be
developed by the development community to create perfect mobileapplications
b Inter-app integration
13
Trang 21With Android, there is no difference between basic phone apps and
third-party apps They are built for equal access to a wide range of phoneapplications and services With devices built on the Android platform, userscan fully satisfy the needs they like We can change the background screen,phone call pattern, or any application We can even instruct the phone to only
view the photos we like
c Higher Success Ratio
Android provides a large library of application programming interfaces and
tools for writing complex applications For example, Android can allowdevelopers to know the device's location and allow devices to communicatewith each other to create a widespread peer-to-peer social network In
addition, Android includes a full set of tools that make development easy
2.1.3 Architecture Android
Android is an open-source and Linux- grounded Operating System for mobile bias
like smartphones and tablet computers Android was developed by the Open
Handset Alliance, led by Google, and other companies Android offers a unified
approach to operation development for mobile bias which means inventors need
only develop for Android, and their operations should be suitable to run on differentbiases powered by Android The first beta interpretation of the Android Software
Development Kit (SDK) was released by Google in 2007 whereas the first
marketable interpretation, Android1.0, was released in September 2008 On June
27, 2012, at the Google I/ O conference, Google blazoned the coming Android
interpretation,4.1 Jellybean Jellybean is an incremental update, with the primary
end of perfecting the stoner interface, both in terms of functionality and
performance The source law for Android is available under free and open-source
software licenses Google publishes the utmost of the law under the Apache Licenseinterpretation2.0 and the rest, Linux kernel changes, under the GNU General PublicLicense interpretation 2 The android platform integrates numerous outstanding
features
14
Trang 22An illustration of the architecture of an android, showing its several key
components and their supporting elements
APPLICATIONS
Contacts Phone Browser
APPLICATION FRAMEWORK
Activity Window Content View Notification
Manager Manager Providers System Manager
Package Telephony Resource Location XMPP Manager Manager Manager Manager Service
LIBRARIES ANDROID RUNTIME
Surface Media Android Runtime
Manager Framework (ART)
Core
LINUX KERNEL
Camera Bluetooth Flash Memory Binder (IPC)
Driver Driver Driver Driver
Figure 2.1 Architecture of Android
a Applications
This is a communication application layer with users, including applicationssuch as basic applications, installed immediately with the operating system iscalling (phone), management of contacts (contacts), browsing the web
(Browser), messaging (SMS), working calendar (Calendar), reading e-mail
15
Trang 23(email-client), map (map), filming (camera) The applications are added as
more like Securities software (stock), games (games), dictionaries
b Application Framework
This layer builds the toolkit - the elements are at a high level so that
programmers can quickly build the application It is written in Java, which
has general usability to save resources
This is an open platform that has 2 advantages:
e For phone manufacturers: Can be customized to suit the phone
configuration they produce as well as to have a variety of models andstyles suitable to user tastes Therefore, despite sharing the same
android platform, Google's phones can be different from Motorola,HTC, T-Mobile, and Samsung
e For programmers: Allows programmers to use the APIs on the upper
tier without having to understand the underlying structure, givingprogrammers the freedom to be creative because they only need tocare about the content that the application they work on A very usefulset of pre-built APIs such as navigation systems, background services,
communication between applications, and high-level interface
components
Introduce some of the components of this section:
e Activity Manager: Manage the life cycles of an application as well as
provide tools to control activities
e Telephony Manage: Provides tools to perform communications such
as phone calls
e XMPP Service: Provides tools for real-time communication.
e Location Manager: Allows to determine the location of the phone
based on the global positioning system GPS and Google Maps
16
Trang 24e@ Window Manager: Manage the construction and display of user
interfaces as well as organize the management of interfaces betweenapplications
e Notification Manager: Manage the display of notifications (such as
alerts with messages, new e-mails, etc.)
e Resource Manager: Manage static resources of applications including
image, sound, layout, and string files (Components that are notwritten in programming languages)
c Libraries and Android runtime
> Android Runtime
Android has a core library set to provide most of the functions
available in the core library of Java programming language
e Android Runtime: including Dalvik virtual machines and
Android libraries
e Basic libraries: Android apps are developed on a Java
environment, but Dalvik is not a Java VM Android's basiclibraries provide oysters with all the functions in Java's basic
library as well as Android's library
e Dalvik Virtual Machine: Dalvik is a virtual machine for
running Android applications, optimized to ensure that onedevice can efficiently run multiple instances It relies on the
Linux kernel for multithreading and low-level memory
management.
This section has many libraries written in C/C++ so that software can
be used, those libraries are gathered into several groups such as:
e System library (System c library): a library based on the c
standard, used only by the operating system
17
Trang 25e Media Libraries: There are many codecs to support the
playback and recording of common audio, image, and video
formats
e Web Library (LibWebCore): This is a component for viewing
content on the web, used to build web browsing software(Android Browse) as well as for other applications to embed It
is extremely powerful, supporting many powerful technologiessuch as HTMLS, JavaScript, CSS, DOM, and AJAX
e SQLite Library: The database system that applications can use
> Libraries
Android provides several APIs for application development The
following list of basic APIs is provided by all Android-based devices:
e android.util: The basic utility package includes many low-level
classes such as management classes (List, Stack ) stringprocessing classes, and XML processing classes
e android.os: An operating system package that provides access
to basic services such as message passing, communication, clocking, and debugging
cross-e android.graphics: Providcross-es low-lcross-evcross-el graphics classcross-es that
perform basic graphics, color, and drawing functions
e@ android.text: Text processing and rendering engine.
e@ android.database: Provides the required low-level classes for
cursor control when working with databases
® android.content: Content programming interfaces used to
manage data access and publishing by providing resourcemanipulation services, Content Providers, and packages
e android.view: View is the most basic user interface layer All
user interfaces are created using a set of Views to providecomponents for user interaction
18
Trang 26e android.widget: Built on top of the View package Widget
classes are pre-built interface components used to create user
interfaces Widgets include lists, buttons, input boxes, and
layouts
e com.google.android.maps: A set of high-level APIs that
provide access to built-in Android map controls from the builtapplication Includes both the MapView class as well as the
Overlay and MapController for interacting with the map insidethe application
e android.app: A package of high-level libraries that provide
access to application data The App Bundle also includes theActivity and Service classes which are the basic components ofevery Android application
e android.provider: To facilitate developer access to standard
Content Providers (such as directory data), the Provider
package includes classes that allow access to the standard
database in all Android distributions
e android.telephony: Telephony APIs that provide direct
interaction with the telephony layer in devices, allowing to
creation, receiving, and track calls, the status of calls, and SMS
messages.
e@ android.webkit: The WebKit package that provides APIs for
working with Web-based content includes a WebView classfor creating web interfaces, embedded in applications, and acookie manager
Along with the Android APIs, there is also a set of C/C++ libraries
such as:
e@ OpenGL: A library for creating 3D graphics based on the
OpenGLES 1.0 API standard
19
Trang 27e FreeType: Supports bitmap and vector font processing.
e GGL: Basic library, used to provide 2D graphics engines
e Libc: The standard c library, optimized for Linux-based
devices SQLite Engine: A lightweight relational database forstoring application data
e SSL: Supports the use of Secure Sockets Layer encryption
protocol in Internet communication security
d Linux Kernel
The android operating system is based on the Linux kernel, specifically
Linux kernel version 2.6, which is shown in this bottom layer All the
operations of the phone that want to be executed are done at a low level at
this layer including memory management, communication with the hardware
(driver model), and security implementation security), and process
management.
This layer has the main components:
e Display Driver: Controls the display on the screen as well as receiving
user controls on the screen (moving, touch )
e Camera Driver: Controls the operation of the camera and receives the
data stream from the camera
e Bluetooth Driver: Controls the Bluetooth transmitter and receiver
e USB driver: Manage the operation of USB communication ports
e Keypad driver: Control the keyboard
e Wi-Fi Driver: Responsible for Wi-Fi reception
e Audio Driver: controls audio transceivers, decoding audio signals into
digital signals and vice versa
e Binder IPC Driver: Responsible for connecting and communicating
with radio networks such as CDMA, GSM, 3G, 4G, and E to ensurecommunication functions are performed
20
Trang 28Android operating system, built on JetBrains’ IntelliJ IDEA software and designed
specifically for Android development It is available for download on Windows,
macOS, and Linux-based operating systems
> Android Studio has more advantages thanks to the following factors:
2.2.2
The WYSIWYG Editor editing interface supports Live-layout that can build
apps and real-time previews
There is an option to preview the interface with multiple settings on multiplescreens when writing the application
Allows creating APK installation files (Android application installation files)
the explosion, here is an example:
21
Trang 29TextView has the following properties:
id: is an attribute to identify it, so that when you need to manipulate
explosion, you can call it easily
e width/height: this is the property to set the width and height for the
textview As the picture is wrap_content width, wrap_content height
e background: to set the color for the background color of the text
view
e textSize: to set the font size
e textColor: Set the color for the text
e fontFamily: set font for text
e textStyle: set style for text (underline, bold, italic )
@ gravity: set the position of the text inside.
® text: the content of the text you want to display In the above
example, the textview will display the content as devpro.edu.vnAnd there are many more properties that depending on the function and
layout have other attributes
EditText
EditText is a control that allows the user to enter, delete, and edit a piece oftext into it Of course, you can also disallow the user to manipulate it LikeTextView, EditText also has its properties
22
Trang 30e id: is the id of EditText, id is usually set according to the prefix +
name structure The example above is name
e width/height: Size of EditText.
@ textSize: Size of text The example above is 18sp
e gravity: set the position of the text inside.
e@ textColor: Set the color for the text.
e textAllCaps: Set uppercase text
e inputType: Type of text when input, it will automatically format
according to the style you choose For example, capital style, datestyle, and email style
e hint: the text suggests to the user a function or a constraint
We can also set many more properties for EditText depending on theapplication's requirements and functions such as margin, text color,and hint color
c Button
The Button is a control that inherits textview, used to set events when the
user manipulates it Like TextView, the button also has the same properties
We must set the event for the button to have an event
23
Trang 31Figure 2.4 Button
e id: is the id of Button, id is usually set according to the prefix + name
structure The example above is btn_status
e width/height: Size of button.
® gravity: set the position of the text inside.
e visibility: Used to set the appearance or hide of the button If "gone" is
Trang 322.3.1
e id: is the id of Spinner, id is usually set according to the prefix + name
structure The example above is bloodGroupSpinner
e width/height: Size of Spinner.
e gravity: set the position of the text inside
e visibility: Used to set the appearance or hide of the button If "gone" is
compile the source code into bytecode, the bytecode is then executed by theenvironment (runtime environment) runs In this way, Java often runs fasterthan other interpreted programming languages like Python, Perl, PHP, etc
What is Java used for?
Since Java is a free and flexible language, it can be used to develop local anddistributed software Some common uses of Java include:
e Writing web applications (J2EE): Java is often used to build large web
systems that require high security, many users such as banks, hospital
management software, CRM, and HRM For small websites usually
very, little is written in Java
e Writing mobile applications (J2ME): Previously the J2ME platform
was often used to write games and apps for mobile feature phones(jar files) and now when Android smartphones take the throne Java
25
Trang 33continues to be used to write apps and games for the Androidplatform (.apk file).
e Writing desktop applications (J2SE): There are not many desktop
applications written in Java, including some software like JMeter orDesigner Vista The biggest advantage of a Java application is thatyou only write it once and then you can bring the program to
Windows, Linux, or Mac to run without having to rewrite it
However, due to running on the JVM, the performance of theapplication is slightly lower than that of languages like C/C++, and
cử
c What to use for Java programming?
To program in Java, we need:
e JDK (Java Development KIT): includes JRE (Java Runtime
Environment) and libraries for development
e IDE (Integrated Development Environment): is an application that
helps programmers develop more easily and quickly You can use
Netbeans, and Eclipse for development
2.3.2 Basic Features of Java [2]
Java is an object-oriented programming language, so it also has four common
characteristics of object-oriented languages:
e Abstraction: is the process of defining and grouping properties and actions
related to a particular entity, about the developing application
e Polymorphism: Allows a method to have different effects on different types
of objects With polymorphism, if the same method applies to objects ofdifferent classes, it will lead to different results The essence of the matter isthat this method includes the same number of parameters
e Inheritance: This allows objects to share or extend existing properties
without having to redefine them
26
Trang 34Encapsulation: The process of hiding the implementation details of an objectfrom the users of that object.
Besides that, Java has some other features:
2.4
2.4.1
Write Once, Run Anywhere: Unlike many other programming languages like
c and c++, when Java is compiled, it is not compiled into machine-specificcode, but instead into bytecode that runs on the machine Java Virtualization
(JVM) This means that any device with a JVM installed will be able toexecute Java programs
Simple: learning Java is much easier than C/C++, if you are familiar withobject-oriented programming languages, learning Java will be easier Javabecomes simpler than C/C++ by removing multiple inheritance and pointermath from C/C++
Security: Java supports security very well through encryption algorithms
such as one-way hashing or public key encryption
Multithreading: With multithreading, Java can write programs that canexecute multiple tasks at the same time This feature is often used a lot ingame programming
High-performance thanks to the garbage collector, which frees memory for
main objects:
Develop & test your app: develop and test designed apps
27
Trang 35e Grow & engage your audience: analyze data and optimize the user
experience
Firebase provides us with simple, important, and cross-platform APIs for managingand using databases
2.4.2 The services [3]
Firebase is a multi-purpose mobile and web application development platform This
platform is a combination of the cloud and Google's server system to focus on two
main objects:
a Real-time Database
Real-time database service allows users to store and synchronize data in time This service is stored directly on iCloud In case your device is offline,they will use up the device's memory and automatically sync to the server
real-Figure 2.6 Real-time Database
You can specify how your data should be formatted, how it should be indexed, andwhen your data can be read from and written using the declarative rules language
that the Realtime Database offers
e Read data
28
Trang 36You need to add a ValueEventListener to the reference you justgenerated to have the data in your app updated in real-time.
Every time the data, including the children, changes, theonDataChange() function in this class is called twice: once when the
Figure 2.7 Read Real-time Database
Trang 37Authentication service provides your application with several authenticationmethods via email, password, phone number, Google account, and Facebookaccount need to use separate registration data.
©
Figure 2.9 Authentication
Sign-in method:
The login method of the Firebase Authentication service set up in the app is
email and password
Allow your users to add an extra layer of security to their account Once enabled, integrated and configured, users can sign in to their account in
two steps, using SMS Leam more
* [MFA and other advanced features are available with Identity Platform, Google Cloud's complete customer identity solution built
in partnership with Firebase This upgrade is available on both the Spark and Blaze plans.
Upgrade to enable
Figure 2.10 Sign-in method
30
Trang 38c Firebase cloud messaging
Firebase was built with chat in mind Therefore, Firebase cloud messaging
(FCM) is the most basic feature of this platform, it allows users to build chatapplications and push notifications to many different devices such as the
web, Android, iOS Highlights of this service is virtual without any codinginvolved FCM is fully integrated with Firebase Analytics, giving you
detailed engagement and conversion tracking along the way
Moreover, the FCM service also allows you to choose when to send
messages immediately or in the future according to the user's local time
hệ Cloud Messaging
Figure 2.11 Cloud messaging
d Firebase database query
One of the outstanding services of Firebase is that it can help you simplify
the process of getting data instead of going through complicated SQL
statements.
Figure 2.12 Firebase database query
31
Trang 392.5 JavaMail [4]
2.5.1 Definition
JavaMail is an API used to compose, send, and read electronic messages (email)
The JavaMail API provides protocol independence and platform independence for
sending and receiving emails That means you don't need to worry about mail
sending and receiving protocols such as SMTP, POP, or IMAP
the user's information The application will send the API with that content to
JavaMail then JavaMail will generate an email to the user with the previously
received content
32
Trang 404 ` Login, registered, email Database communication
i mm Welcome, Blood DonationApp
By People & sharing
Payments & subscriptions
Privacy & You have security
oa personalization 3 recommendations ý
Manage your data & privacy Protect your account
Privacy Checkup
Take Privacy Checkup
Looking for something else?
Q_ Search Google Account >
Figure 2.15 Blood Donation Gmail
b Library
33