• onPause(): called when the activity has to be moved in second position of the stack. Here all non-
needed resources are released (e.g., persisting data is committed, listeners unregistered).
• onStop(): called when the activity is no more visible to the user. Next possible notification can be
onRestart() or onDestroy().
• onDestroy(): activity terminated and removed from memory.
In the onCreate() method it is needed to prepare a View and make it visible. It is in charge of presenting
content to the user and is usually made of elementary widgets connected together to form a visual tree.
Android uses the composite pattern to build the hierarchy. Among the view subclasses there are the
elementary views (which are leaves in the tree) and view containers which can internally host other views. It
is possible to create the hierarchy in three ways:
• Programmatically by direct instantiation of elements. This gives flexibility because they are built
based on actual data, but also control since everything is created explicitly from the programmer.
The problem is that maintenance is difficult and does not support internationalization.
• Via XML files by naming each file with a unique ID and then by inflating it from the code. Each
element of the tree will have a unique ID too, to be managed also via code. It is easy to maintain, and
the visual editor helps building the XML files. The problem is that each element needs an ID, and they
must be kept in sync between the various XML representations.
• Using Jetpack Compose library, which is inspired from React and it can describe declaratively the
content and the behavior of the view. Each view is represented as a function labelled
“@Composable”. The problem is that it requires programming skills and designer find the XML files
more intuitive.
Intent is an asynchronous messaging mechanism used by the OS to associate process requests with activities.
They can be:
• Implicit: the action to be performed is indicated and the OS will find the component that is able to
handle it. In this case it is provided the action, the URI (resource id) and the category.
• Explicit: It ask the OS to activate a specific component within the application process.
Intents can be enriched with bundles in the form of key/value pairs. Intents can also be broadcasted and
anyone who registered a listener will receive it. Typically used to generate system wide notifications.
All the elements of an application (Activity, Service, Content Provider, Broadcast Receiver) have a common
root: the Context. It provides the functionalities to access resources (identified by unique ID in the project)
and all the application-specific classes, but also to interact with the OS.
Graphical User Interface
The usage of graphic tools facilitates in terms of operational level the design of user interfaces, but still there
are:
• Cognitive issues: building a pleasing, functional and easy to learn interface is challenging. The design
of informational flow and graphic contents must be done carefully, otherwise user will get confused
and stop using the application.
• Operational issues: mobile devices vary widely in terms of physical dimensions, screen resolution
and orientation, dot density. A set of possible alternative configurations should be designed by also
taking in account the different languages, cultures and metaphors and level of confidence.
General guidelines says that the first step is related to the analysis of the context and the processes to be
supported, the second step subdivide complex tasks into smaller ones, while the third step relies on general
principles of interaction design.