Lecture 2 - Android Environment Fundamentals
Lecture 2 - Android Environment Fundamentals
Lecture 2 - Android Environment Fundamentals
Lecture 2 – Android
Environment
Fundamentals
Application Fundamentals
Application Components
Android Studio
Creating a Project
Project Files
First Application
Application Fundamentals
Android apps can be written using Kotlin, Java, and C++ languages.
An Android package, which is an archive file with an .apk suffix, contains
the contents of an Android app that are required at runtime, Android-
powered devices use to install the app.
An Android App Bundle, which is an archive file with an .aab suffix, contains
the contents of an Android app project including some additional
metadata that is not required at runtime.
Application Fundamentals
Each Android app lives in its own security sandbox, protected by the
following Android security features:
The Android operating system is a multi-user Linux system in which each app is a
different user.
By default, the system assigns each app a unique Linux user ID (the ID is used only
by the system and is unknown to the app).
Each process has its own virtual machine (VM), so an app's code runs in isolation
from other apps.
By default, every app runs in its own Linux process.
Application Fundamentals
There are ways for an app to share data with other apps and for an
app to access system services:
It's possible to arrange for two apps to share the same Linux user ID, in
which case they can access each other's files. To conserve system
resources, apps with the same user ID can also arrange to run in the
same Linux process and share the same VM. The apps must also be
signed with the same certificate.
An app can request permission to access device data such as the
device's location, camera, and Bluetooth connection. The user must
explicitly grant these permissions.
Application Components
An activity is the entry point for interacting with the user (a single screen).
Although the activities work together to form a cohesive user experience in
the email app, each one is independent of the others.
For example, a camera app can start the activity in the email app that
composes new mail to allow the user to share a picture.
You implement an activity as a subclass of the Activity class.
Services
A content provider manages a shared set of app data that you can store in
the file system, in an SQLite database, on the web, or on any other
persistent storage location that your app can access.
Through the content provider, other apps can query or modify the data if
the content provider allows it.
Content providers are also useful for reading and writing data that is private
to your app and not shared.
A content provider is implemented as a subclass of ContentProvider and
must implement a standard set of APIs that enable other apps to perform
transactions.
Application Fundamentals
A unique aspect of the Android system design is that any app can start
another app’s component.
When the system starts a component, it starts the process for that app if it's
not already running and instantiates the classes needed for the
component.
Therefore, unlike apps on most other systems, Android apps don't have a
single-entry point (there's no main() function).
To activate a component in another app, deliver a message to the system
that specifies your intent to start a particular component. The system then
activates the component for you.
Activating Components
Android view
Project view
Application Code
https://developer.android.com/codelabs/basic-android-kotlin-compose-
first-app#1
Summary
To create a new project: Open Android Studio, click New Project > Empty
Compose Activity > Next, enter a name for your project and then configure
its settings.
To see how your app looks, use the Preview pane.
Composable functions are like regular functions with a few differences:
functions names are capitalized, you add the @Composable annotation
before the function, @Composable functions can't return anything.
A Modifier is used to augment or decorate your composable.
References
https://developer.android.com/guide/components/fundamentals