13
© Peter Späth 2018
P. Späth,
Pro Android with Kotlin
,
https://doi.org/10.1007/978-1-4842-3820-2_3
Chapter
3
Activities
Activities
represent user interface entry points of your app. Any app that needs to interact
functionally with the user in a direct way, by letting the user enter things or telling the
user graphically about
the functional state of an app, will expose at least one
activity
to
the system. I say
functionally
because telling the user about events can also happen via
notifications through
toasts
or the
status bar
, for which an activity is not needed.
Apps can have zero, one,
or more activities, and they get started in one of two ways:
The
main activity
, as declared inside
AndroidManifest.xml
, gets started
by launching the app. This
is kind of similar to the
main()
function of
traditional applications.
All activities can be configured to be started by an explicit or implicit
intent
, as configured inside
AndroidManifest.xml
. Intents are both
objects of a class and a new concept in Android.
With explicit intents,
by triggering an intent, a component specifies that it needs something
to be done by a dedicated component of a dedicated app. For implicit
intents, the component just tells what needs to be done without
specifying which component is supposed to do it.
The Android OS or
the user decides which app or component is capable of fulfilling such an
implicit request.
From a user perspective, activities show up as things that can be started from inside an
application launcher, be it the standard launcher or a specialized third-party launcher app.
As
soon as they are running, they show up in a task stack as well, and users will see them
when using the Back button.