android & java frameworks: introductionschmidt/cs891s/2019-pdfs/12.2.1...25 overview of...
TRANSCRIPT
![Page 1: Android & Java Frameworks: Introductionschmidt/cs891s/2019-PDFs/12.2.1...25 Overview of Frameworks in Android & Java •The control flow in framework-driven Android apps traverses](https://reader034.vdocuments.mx/reader034/viewer/2022042807/5f78b549d328b40c754549ac/html5/thumbnails/1.jpg)
Android & Java Frameworks:
Introduction
Douglas C. [email protected]
www.dre.vanderbilt.edu/~schmidt
Institute for Software
Integrated Systems
Vanderbilt University
Nashville, Tennessee, USA
![Page 2: Android & Java Frameworks: Introductionschmidt/cs891s/2019-PDFs/12.2.1...25 Overview of Frameworks in Android & Java •The control flow in framework-driven Android apps traverses](https://reader034.vdocuments.mx/reader034/viewer/2022042807/5f78b549d328b40c754549ac/html5/thumbnails/2.jpg)
2
Learning Objectives in this Part of the Lesson• Understand how software frameworks are used in Android & Java
![Page 3: Android & Java Frameworks: Introductionschmidt/cs891s/2019-PDFs/12.2.1...25 Overview of Frameworks in Android & Java •The control flow in framework-driven Android apps traverses](https://reader034.vdocuments.mx/reader034/viewer/2022042807/5f78b549d328b40c754549ac/html5/thumbnails/3.jpg)
3
Overview of Frameworksin Android
![Page 4: Android & Java Frameworks: Introductionschmidt/cs891s/2019-PDFs/12.2.1...25 Overview of Frameworks in Android & Java •The control flow in framework-driven Android apps traverses](https://reader034.vdocuments.mx/reader034/viewer/2022042807/5f78b549d328b40c754549ac/html5/thumbnails/4.jpg)
4
Overview of Frameworks in Android & Java
See www.dre.vanderbilt.edu/~schmidt/frameworks.html
• A framework is an integrated set of components that provide a reusable architecture for a family of related apps
![Page 5: Android & Java Frameworks: Introductionschmidt/cs891s/2019-PDFs/12.2.1...25 Overview of Frameworks in Android & Java •The control flow in framework-driven Android apps traverses](https://reader034.vdocuments.mx/reader034/viewer/2022042807/5f78b549d328b40c754549ac/html5/thumbnails/5.jpg)
5See en.wikipedia.org/wiki/Inversion_of_control &
en.wikipedia.org/wiki/Callback_(computer_programming)
Overview of Frameworks in Android & Java• A framework is an integrated set of components that provide a reusable
architecture for a family of related apps & exhibits three key characteristics
• Exhibit “inversion of control” (IoC) via callbacks
Looper
FutureTask
MessageQueue
HandlerExecutor
…Runnable…
Message
![Page 6: Android & Java Frameworks: Introductionschmidt/cs891s/2019-PDFs/12.2.1...25 Overview of Frameworks in Android & Java •The control flow in framework-driven Android apps traverses](https://reader034.vdocuments.mx/reader034/viewer/2022042807/5f78b549d328b40c754549ac/html5/thumbnails/6.jpg)
6
Overview of Frameworks in Android & Java• A framework is an integrated set of components that provide a reusable
architecture for a family of related apps & exhibits three key characteristics
• Exhibit “inversion of control” (IoC) via callbacks
• Integrated domain-specificstructure & functionality
Application-specific functionality
Domain-specific functionality for concurrent Android programs
Looper
FutureTask
MessageQueue
HandlerExecutor
…Runnable…
Message
![Page 7: Android & Java Frameworks: Introductionschmidt/cs891s/2019-PDFs/12.2.1...25 Overview of Frameworks in Android & Java •The control flow in framework-driven Android apps traverses](https://reader034.vdocuments.mx/reader034/viewer/2022042807/5f78b549d328b40c754549ac/html5/thumbnails/7.jpg)
7
Overview of Frameworks in Android & Java• A framework is an integrated set of components that provide a reusable
architecture for a family of related apps & exhibits three key characteristics
• Exhibit “inversion of control” (IoC) via callbacks
• Integrated domain-specificstructure & functionality
• Provide semi-complete (portions of) apps
Application-specific functionality
Domain-specific functionality for concurrent Android programs
Looper
FutureTask
MessageQueue
HandlerExecutor
…Runnable…
Message
See www.laputan.org/drc/drc.html
![Page 8: Android & Java Frameworks: Introductionschmidt/cs891s/2019-PDFs/12.2.1...25 Overview of Frameworks in Android & Java •The control flow in framework-driven Android apps traverses](https://reader034.vdocuments.mx/reader034/viewer/2022042807/5f78b549d328b40c754549ac/html5/thumbnails/8.jpg)
8
Overview of Frameworks in Android & Java• A framework is an integrated set of components that provide a reusable
architecture for a family of related apps & exhibits three key characteristics
• Exhibit “inversion of control” (IoC) via callbacks
• Integrated domain-specificstructure & functionality
• Provide semi-complete (portions of) apps
Application-specific functionality
Domain-specific functionality for concurrent Android programs
Looper
FutureTask
MessageQueue
HandlerExecutor
…Runnable…
Message
See next part of lesson on “Android & Java Frameworks: Key Characteristics”
![Page 9: Android & Java Frameworks: Introductionschmidt/cs891s/2019-PDFs/12.2.1...25 Overview of Frameworks in Android & Java •The control flow in framework-driven Android apps traverses](https://reader034.vdocuments.mx/reader034/viewer/2022042807/5f78b549d328b40c754549ac/html5/thumbnails/9.jpg)
9
Overview of Frameworks in Android & Java• Android & Java provide many frameworks
![Page 10: Android & Java Frameworks: Introductionschmidt/cs891s/2019-PDFs/12.2.1...25 Overview of Frameworks in Android & Java •The control flow in framework-driven Android apps traverses](https://reader034.vdocuments.mx/reader034/viewer/2022042807/5f78b549d328b40c754549ac/html5/thumbnails/10.jpg)
10
Overview of Frameworks in Android & Java
See developer.android.com/training/multiple-threads/communicate-ui.html
• Android & Java provide many frameworks, e.g.
• Android
• Android’s Activity framework manages lifecycle hook methodsdispatched in the UI thread
![Page 11: Android & Java Frameworks: Introductionschmidt/cs891s/2019-PDFs/12.2.1...25 Overview of Frameworks in Android & Java •The control flow in framework-driven Android apps traverses](https://reader034.vdocuments.mx/reader034/viewer/2022042807/5f78b549d328b40c754549ac/html5/thumbnails/11.jpg)
11
Overview of Frameworks in Android & Java
See developer.android.com/training/basics/activity-lifecycle
• Android & Java provide many frameworks, e.g.
• Android
• Android’s Activity framework manages lifecycle hook methodsdispatched in the UI thread
• e.g., onCreate(), onStart(), onStop(), onDestroy(), etc.
![Page 12: Android & Java Frameworks: Introductionschmidt/cs891s/2019-PDFs/12.2.1...25 Overview of Frameworks in Android & Java •The control flow in framework-driven Android apps traverses](https://reader034.vdocuments.mx/reader034/viewer/2022042807/5f78b549d328b40c754549ac/html5/thumbnails/12.jpg)
12
public void
onClick(View v)
{
...
}
ClickListenerObject
GUI Component(a button)
A GUI component sending an event to its registered listener
Overview of Frameworks in Android & Java• Android & Java provide many frameworks, e.g.
• Android
• Android’s Activity framework manages lifecycle hook methodsdispatched in the UI thread
• A listener for button clicks is called back by Android’s GUI framework
![Page 13: Android & Java Frameworks: Introductionschmidt/cs891s/2019-PDFs/12.2.1...25 Overview of Frameworks in Android & Java •The control flow in framework-driven Android apps traverses](https://reader034.vdocuments.mx/reader034/viewer/2022042807/5f78b549d328b40c754549ac/html5/thumbnails/13.jpg)
13
Overview of Frameworks in Android & Java
See docs.oracle.com/javase/tutorial/essential/concurrency/runthread.html
• Android & Java provide many frameworks, e.g.
• Android
• Java
• A thread invokes the run() hook method of a runnable
![Page 14: Android & Java Frameworks: Introductionschmidt/cs891s/2019-PDFs/12.2.1...25 Overview of Frameworks in Android & Java •The control flow in framework-driven Android apps traverses](https://reader034.vdocuments.mx/reader034/viewer/2022042807/5f78b549d328b40c754549ac/html5/thumbnails/14.jpg)
14
Overview of Frameworks in Android & Java
ExecutorService
WorkerThreads
run()
3.take()
4.call()
callable
WorkQueue
2.offer()
callable
submit()
1.submit(callable)
Thread
See docs.oracle.com/javase/tutorial/essential/concurrency/executors.html
• Android & Java provide many frameworks, e.g.
• Android
• Java
• A thread invokes the run() hook method of a runnable
• The ExecutorService invokes the call() hook method of a callable
![Page 15: Android & Java Frameworks: Introductionschmidt/cs891s/2019-PDFs/12.2.1...25 Overview of Frameworks in Android & Java •The control flow in framework-driven Android apps traverses](https://reader034.vdocuments.mx/reader034/viewer/2022042807/5f78b549d328b40c754549ac/html5/thumbnails/15.jpg)
15
• All Android apps run inside one or more software frameworks
Overview of Frameworks in Android & Java
Your mobile apps must use multiple Android frameworks
Service Manager
System Server Process
TelephonyManagerService
Activity ManagerService
DownloadManagerService
LocationManagerService
NotificationManagerService
PackageManagerService
WindowManagerService
…Service
Init
Zygote
![Page 16: Android & Java Frameworks: Introductionschmidt/cs891s/2019-PDFs/12.2.1...25 Overview of Frameworks in Android & Java •The control flow in framework-driven Android apps traverses](https://reader034.vdocuments.mx/reader034/viewer/2022042807/5f78b549d328b40c754549ac/html5/thumbnails/16.jpg)
16
• All Android apps run inside one or more software frameworks
• The motivation for using so many frameworks is to enhance systematic reuse
Overview of Frameworks in Android & Java
See en.wikipedia.org/wiki/Code_reuse#Systematic_software_reuse
![Page 17: Android & Java Frameworks: Introductionschmidt/cs891s/2019-PDFs/12.2.1...25 Overview of Frameworks in Android & Java •The control flow in framework-driven Android apps traverses](https://reader034.vdocuments.mx/reader034/viewer/2022042807/5f78b549d328b40c754549ac/html5/thumbnails/17.jpg)
17
• All Android apps run inside one or more software frameworks
• The motivation for using so many frameworks is to enhance systematic reuse
• Apps (& app developers) thus don’t need to “reinvent the wheel”
Overview of Frameworks in Android & Java
See en.wikipedia.org/wiki/Reinventing_the_wheel
![Page 18: Android & Java Frameworks: Introductionschmidt/cs891s/2019-PDFs/12.2.1...25 Overview of Frameworks in Android & Java •The control flow in framework-driven Android apps traverses](https://reader034.vdocuments.mx/reader034/viewer/2022042807/5f78b549d328b40c754549ac/html5/thumbnails/18.jpg)
18
• Android frameworks use an event-driven programming model to integrate app classes into them
See en.wikipedia.org/wiki/Event-driven_programming
Overview of Frameworks in Android & Java
![Page 19: Android & Java Frameworks: Introductionschmidt/cs891s/2019-PDFs/12.2.1...25 Overview of Frameworks in Android & Java •The control flow in framework-driven Android apps traverses](https://reader034.vdocuments.mx/reader034/viewer/2022042807/5f78b549d328b40c754549ac/html5/thumbnails/19.jpg)
19
• Android frameworks use an event-driven programming model to integrate app classes into them
• In this programming paradigm, theflow of the program is determined by events, e.g.
• User actions (button presses,gestures, etc.)
• Sensor inputs/outputs
• Messages from other threads
Overview of Frameworks in Android & Java
See en.wikipedia.org/wiki/Event-driven_programming
![Page 20: Android & Java Frameworks: Introductionschmidt/cs891s/2019-PDFs/12.2.1...25 Overview of Frameworks in Android & Java •The control flow in framework-driven Android apps traverses](https://reader034.vdocuments.mx/reader034/viewer/2022042807/5f78b549d328b40c754549ac/html5/thumbnails/20.jpg)
20
• The control flow in framework-driven Android apps traverses between the framework(s) & the app classes
Overview of Frameworks in Android & Java
Register for event
ApplicationCode
FrameworkCode
Eventoccurs
Eventoccurs
e.g., create an activity, service, and/or broadcast receiver
![Page 21: Android & Java Frameworks: Introductionschmidt/cs891s/2019-PDFs/12.2.1...25 Overview of Frameworks in Android & Java •The control flow in framework-driven Android apps traverses](https://reader034.vdocuments.mx/reader034/viewer/2022042807/5f78b549d328b40c754549ac/html5/thumbnails/21.jpg)
21
• The control flow in framework-driven Android apps traverses between the framework(s) & the app classes
Overview of Frameworks in Android & Java
Register for event
Eventoccurs
Eventoccurs
ApplicationCode
FrameworkCode
e.g., a message occurs that triggers a lifecycle event
![Page 22: Android & Java Frameworks: Introductionschmidt/cs891s/2019-PDFs/12.2.1...25 Overview of Frameworks in Android & Java •The control flow in framework-driven Android apps traverses](https://reader034.vdocuments.mx/reader034/viewer/2022042807/5f78b549d328b40c754549ac/html5/thumbnails/22.jpg)
22
• The control flow in framework-driven Android apps traverses between the framework(s) & the app classes
• A framework calls to app codewhen an event of interest occurs
Overview of Frameworks in Android & Java
Register for event
Eventoccurs
Eventoccurs
ApplicationCode
FrameworkCode
e.g., dispatch lifecycle hook methods like onCreate(), onStart(), onReceive(), etc.
![Page 23: Android & Java Frameworks: Introductionschmidt/cs891s/2019-PDFs/12.2.1...25 Overview of Frameworks in Android & Java •The control flow in framework-driven Android apps traverses](https://reader034.vdocuments.mx/reader034/viewer/2022042807/5f78b549d328b40c754549ac/html5/thumbnails/23.jpg)
23
Overview of Frameworks in Android & Java• The control flow in framework-driven
Android apps traverses between the framework(s) & the app classes
• A framework calls to app codewhen an event of interest occurs
Register for event
Eventoccurs
Eventoccurs
ApplicationCode
FrameworkCode
e.g., the app performs its processing in the context of framework thread(s)
![Page 24: Android & Java Frameworks: Introductionschmidt/cs891s/2019-PDFs/12.2.1...25 Overview of Frameworks in Android & Java •The control flow in framework-driven Android apps traverses](https://reader034.vdocuments.mx/reader034/viewer/2022042807/5f78b549d328b40c754549ac/html5/thumbnails/24.jpg)
24
Overview of Frameworks in Android & Java• The control flow in framework-driven
Android apps traverses between the framework(s) & the app classes
• A framework calls to app codewhen an event of interest occurs
• Control returns to the framework after an app callback is done
Register for event
Eventoccurs
Eventoccurs
ApplicationCode
FrameworkCode
![Page 25: Android & Java Frameworks: Introductionschmidt/cs891s/2019-PDFs/12.2.1...25 Overview of Frameworks in Android & Java •The control flow in framework-driven Android apps traverses](https://reader034.vdocuments.mx/reader034/viewer/2022042807/5f78b549d328b40c754549ac/html5/thumbnails/25.jpg)
25
Overview of Frameworks in Android & Java• The control flow in framework-driven
Android apps traverses between the framework(s) & the app classes
• A framework calls to app codewhen an event of interest occurs
• Control returns to the framework after an app callback is done
• Lather, rinse, repeat until app is done …
Register for event
Eventoccurs
Eventoccurs
ApplicationCode
FrameworkCode
See en.wikipedia.org/wiki/Lather,_rinse,_repeat
![Page 26: Android & Java Frameworks: Introductionschmidt/cs891s/2019-PDFs/12.2.1...25 Overview of Frameworks in Android & Java •The control flow in framework-driven Android apps traverses](https://reader034.vdocuments.mx/reader034/viewer/2022042807/5f78b549d328b40c754549ac/html5/thumbnails/26.jpg)
26
Overview of Frameworks in Android & Java• The control flow in framework-driven
Android apps traverses between the framework(s) & the app classes
• A framework calls to app codewhen an event of interest occurs
• Control returns to the framework after an app callback is done
• Lather, rinse, repeat until app is done …
Register for event
Eventoccurs
Eventoccurs
ApplicationCode
FrameworkCode
See www.sei.cmu.edu/reports/95tr021.pdf
Separating concerns this way helps enhance systematic software reuse & improve various quality attributes
![Page 27: Android & Java Frameworks: Introductionschmidt/cs891s/2019-PDFs/12.2.1...25 Overview of Frameworks in Android & Java •The control flow in framework-driven Android apps traverses](https://reader034.vdocuments.mx/reader034/viewer/2022042807/5f78b549d328b40c754549ac/html5/thumbnails/27.jpg)
27
End of Android & Java Frameworks: Introduction