![Page 1: Overview of Android: Key App Componentsschmidt/cs891s/2020-PDFs/11.3.4-overvie… · 2 Learning Objectives in this Part of the Lesson 1. Understand key elements in Android’s middleware](https://reader035.vdocuments.us/reader035/viewer/2022082006/60151a504c4ac57d9720245c/html5/thumbnails/1.jpg)
Overview of Android: Key App Components
Douglas C. Schmidt
www.dre.vanderbilt.edu/~schmidt
Professor of Computer Science
Institute for Software
Integrated Systems
Vanderbilt University
Nashville, Tennessee, USA
![Page 2: Overview of Android: Key App Componentsschmidt/cs891s/2020-PDFs/11.3.4-overvie… · 2 Learning Objectives in this Part of the Lesson 1. Understand key elements in Android’s middleware](https://reader035.vdocuments.us/reader035/viewer/2022082006/60151a504c4ac57d9720245c/html5/thumbnails/2.jpg)
2
Learning Objectives in this Part of the Lesson1. Understand key elements
in Android’s middleware infrastructure
2. Name all the key app components in Android
![Page 3: Overview of Android: Key App Componentsschmidt/cs891s/2020-PDFs/11.3.4-overvie… · 2 Learning Objectives in this Part of the Lesson 1. Understand key elements in Android’s middleware](https://reader035.vdocuments.us/reader035/viewer/2022082006/60151a504c4ac57d9720245c/html5/thumbnails/3.jpg)
3
Overview of Key Android App Components
![Page 4: Overview of Android: Key App Componentsschmidt/cs891s/2020-PDFs/11.3.4-overvie… · 2 Learning Objectives in this Part of the Lesson 1. Understand key elements in Android’s middleware](https://reader035.vdocuments.us/reader035/viewer/2022082006/60151a504c4ac57d9720245c/html5/thumbnails/4.jpg)
4
Overview of Key Android App Components• App components are essential building
blocks of mobile apps that provide various hooks via which Android can effect an app’s lifecycle
See developer.android.com/guide/components/fundamentals.html#Components
Content
Provider
ServiceActivity
Broadcast
Receiver
![Page 5: Overview of Android: Key App Componentsschmidt/cs891s/2020-PDFs/11.3.4-overvie… · 2 Learning Objectives in this Part of the Lesson 1. Understand key elements in Android’s middleware](https://reader035.vdocuments.us/reader035/viewer/2022082006/60151a504c4ac57d9720245c/html5/thumbnails/5.jpg)
5
• Intent
• A message that describes an action toperform or an event that has occurred
See developer.android.com/reference/android/content/Intent.html
Overview of Key Android App Components
![Page 6: Overview of Android: Key App Componentsschmidt/cs891s/2020-PDFs/11.3.4-overvie… · 2 Learning Objectives in this Part of the Lesson 1. Understand key elements in Android’s middleware](https://reader035.vdocuments.us/reader035/viewer/2022082006/60151a504c4ac57d9720245c/html5/thumbnails/6.jpg)
6
• Intent
• A message that describes an action toperform or an event that has occurred
• Android uses intents as “glue” to simplify the integration of apps that reuse existing components
Service
Intent
<...
android:name="..."
<intent-filter>
<action android:name="..." />
</intent-filter>
</...>
BroadcastReceiver
Activity
Overview of Key Android App Components✓ Name, Action
✓ Data, Category
✓ Extras, Flags
![Page 7: Overview of Android: Key App Componentsschmidt/cs891s/2020-PDFs/11.3.4-overvie… · 2 Learning Objectives in this Part of the Lesson 1. Understand key elements in Android’s middleware](https://reader035.vdocuments.us/reader035/viewer/2022082006/60151a504c4ac57d9720245c/html5/thumbnails/7.jpg)
7
• Activity
• Provides a screen within which users can interact to do a single focused thing
Overview of Key Android App Components
See developer.android.com/reference/android/app/Activity.html
![Page 8: Overview of Android: Key App Componentsschmidt/cs891s/2020-PDFs/11.3.4-overvie… · 2 Learning Objectives in this Part of the Lesson 1. Understand key elements in Android’s middleware](https://reader035.vdocuments.us/reader035/viewer/2022082006/60151a504c4ac57d9720245c/html5/thumbnails/8.jpg)
8
• Activity
• Provides a screen within which users can interact to do a single focused thing
• It’s the most common type of Android component
Overview of Key Android App Components
See developer.android.com/guide/components/activities.html
![Page 9: Overview of Android: Key App Componentsschmidt/cs891s/2020-PDFs/11.3.4-overvie… · 2 Learning Objectives in this Part of the Lesson 1. Understand key elements in Android’s middleware](https://reader035.vdocuments.us/reader035/viewer/2022082006/60151a504c4ac57d9720245c/html5/thumbnails/9.jpg)
9
• Activity
• Provides a screen within which users can interact to do a single focused thing
• It’s the most common type of Android component
Overview of Key Android App Components
Activities are at the heart of all Android apps
![Page 10: Overview of Android: Key App Componentsschmidt/cs891s/2020-PDFs/11.3.4-overvie… · 2 Learning Objectives in this Part of the Lesson 1. Understand key elements in Android’s middleware](https://reader035.vdocuments.us/reader035/viewer/2022082006/60151a504c4ac57d9720245c/html5/thumbnails/10.jpg)
10
• Broadcast Receiver
• Event handler that can respond to system-wide broadcasts
See developer.android.com/reference/android/content/BroadcastReceiver.html
Overview of Key Android App Components
![Page 11: Overview of Android: Key App Componentsschmidt/cs891s/2020-PDFs/11.3.4-overvie… · 2 Learning Objectives in this Part of the Lesson 1. Understand key elements in Android’s middleware](https://reader035.vdocuments.us/reader035/viewer/2022082006/60151a504c4ac57d9720245c/html5/thumbnails/11.jpg)
11
• Broadcast Receiver
• Event handler that can respond to system-wide broadcasts
• Activities & services in 1+ apps can interact by broadcasting intents handled by 0+ broadcast receivers
Overview of Key Android App Components
PhoneApp
System Server
Broadcast Receivers
Battery Service
Activity Manager Service
![Page 12: Overview of Android: Key App Componentsschmidt/cs891s/2020-PDFs/11.3.4-overvie… · 2 Learning Objectives in this Part of the Lesson 1. Understand key elements in Android’s middleware](https://reader035.vdocuments.us/reader035/viewer/2022082006/60151a504c4ac57d9720245c/html5/thumbnails/12.jpg)
12See developer.android.com/reference/android/app/Service.html
• Service
• Runs in background to perform long-running operations or access remote resources
Overview of Key Android App Components
![Page 13: Overview of Android: Key App Componentsschmidt/cs891s/2020-PDFs/11.3.4-overvie… · 2 Learning Objectives in this Part of the Lesson 1. Understand key elements in Android’s middleware](https://reader035.vdocuments.us/reader035/viewer/2022082006/60151a504c4ac57d9720245c/html5/thumbnails/13.jpg)
13
• Service
• Runs in background to perform long-running operations or access remote resources
• A bound service has a lifecycle that depends on its creating component(s)
Overview of Key Android App Components
See developer.android.com/guide/components/services.html
![Page 14: Overview of Android: Key App Componentsschmidt/cs891s/2020-PDFs/11.3.4-overvie… · 2 Learning Objectives in this Part of the Lesson 1. Understand key elements in Android’s middleware](https://reader035.vdocuments.us/reader035/viewer/2022082006/60151a504c4ac57d9720245c/html5/thumbnails/14.jpg)
14
• Service
• Runs in background to perform long-running operations or access remote resources
• A bound service has a lifecycle that depends on its creating component(s)
• A started service’s lifecycle doesn’t depend on its creating component
Overview of Key Android App Components
Started services are deprecated in later versions of Android
![Page 15: Overview of Android: Key App Componentsschmidt/cs891s/2020-PDFs/11.3.4-overvie… · 2 Learning Objectives in this Part of the Lesson 1. Understand key elements in Android’s middleware](https://reader035.vdocuments.us/reader035/viewer/2022082006/60151a504c4ac57d9720245c/html5/thumbnails/15.jpg)
15
• Content Provider
• Manages access to structured data & provides data security mechanisms
See developer.android.com/reference/android/content/ContentProvider.html
Overview of Key Android App Components
![Page 16: Overview of Android: Key App Componentsschmidt/cs891s/2020-PDFs/11.3.4-overvie… · 2 Learning Objectives in this Part of the Lesson 1. Understand key elements in Android’s middleware](https://reader035.vdocuments.us/reader035/viewer/2022082006/60151a504c4ac57d9720245c/html5/thumbnails/16.jpg)
16
• Content Provider
• Manages access to structured data & provides data security mechanisms
• Content Providers/Resolvers can make an app’s data available to other apps
See developer.android.com/guide/topics/providers/content-providers.html
Overview of Key Android App Components
![Page 17: Overview of Android: Key App Componentsschmidt/cs891s/2020-PDFs/11.3.4-overvie… · 2 Learning Objectives in this Part of the Lesson 1. Understand key elements in Android’s middleware](https://reader035.vdocuments.us/reader035/viewer/2022082006/60151a504c4ac57d9720245c/html5/thumbnails/17.jpg)
17
Overview of Key Android App Components• We cover intents, activities, & broadcast
receivers in MOOC 2 & services & content providers in MOOC 3 of the Android App Development specialization
Content
Provider
ServiceActivity
Broadcast
Receiver
See www.coursera.org/specializations/android-app-development
![Page 18: Overview of Android: Key App Componentsschmidt/cs891s/2020-PDFs/11.3.4-overvie… · 2 Learning Objectives in this Part of the Lesson 1. Understand key elements in Android’s middleware](https://reader035.vdocuments.us/reader035/viewer/2022082006/60151a504c4ac57d9720245c/html5/thumbnails/18.jpg)
18
End of Overview of Android: Key App Components