0% found this document useful (0 votes)
10 views14 pages

App Mob

The document provides an overview of mobile applications, focusing on types such as native, web, and hybrid applications, and their respective characteristics. It details the Android operating system's architecture, development environment, and activity lifecycle, emphasizing user experience and resource management. Additionally, it covers advanced concepts like fragments, intents, and data persistence, essential for developing high-quality mobile applications.

Uploaded by

walidzetshi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views14 pages

App Mob

The document provides an overview of mobile applications, focusing on types such as native, web, and hybrid applications, and their respective characteristics. It details the Android operating system's architecture, development environment, and activity lifecycle, emphasizing user experience and resource management. Additionally, it covers advanced concepts like fragments, intents, and data persistence, essential for developing high-quality mobile applications.

Uploaded by

walidzetshi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Chapter 1: Introduction

Definition:
An Application: un logiciel applicatif conçu pour s’exécuter à partir du système
d’exploitation.

Les types d’application mobile:


Application native: run exclusively on their intended OS, can only be found in the app stores
which take 25% of a native app’s price, require memory allocation, offer more features and
provide better quality, and they are faster as they are made to run on the specified OS.
Application web: developed with HTML, CSS, JS, and backend with whatever (I suggest
Quasar), they are accessible from all platforms, and they are less costly = more beneficial, and
consume less time, but are slower in execution.
Application hybride: web application wrapped as an executable file to be executed on any OS,
which is advantageous, you can imagine them as web browsers which open a specific
website.
Comparison between these three kinds is done by measuring the cost, and the speed [of
execution].

Operation Systems:
Un système d’exploitation mobile est un ensemble de programmes qui gère les opérations, le
contrôle, la coordination, l'utilisation du matériel et le partage des ressources d'un appareil
entre les programmes qui s'y exécutent. C'est une plateforme logicielle permettant aux
applications de fonctionner sur des appareils mobiles. Il est important de noter que les
systèmes d’exploitation mobiles varient en fonction des fonctionnalités qu'ils prennent en
charge.

Characteristics:
regroupe un ensemble des fonctionnalités; dont: la gestion de la mémoire, des
microprocesseurs et l’ordonnancement, de systèmes de fichiers, des I./O., de sécurité, de
fonctionnalités multimédia, etc.

Android:
Based on Linux, owned by Google, runs on phones, TVs, cars, smart glasses, etc.
It is open source, free, easy to develop applications on (because of the many near-perfect,
easy to access APIs), easy to sell (GooglePlay), flexible (can run on many structures).

Structure:
Is based on: Linux Kernel, libraries, the application development module, and the different
applications.
Kernel: Le noyau est l’élément du système d’exploitation qui représente la passerelle entre la
partie matérielle et la partie logicielle. It is Linux. It manages the basic layers: material and
the operations directed to them. The kernel used is developed to fit the Android mobile
exclusively, with advanced power management.
Libraries: many libraries in c/c++ offering advanced services.
L’environnement d’exécution (Android runtime): similar to Java’s virtual machine concept,
but it’s lighter, and found on the same level as libraries. Android apps must be compiled using
“dx”, which compiles .java into .class, and .class into .dex, a Dalvik Executable. This is not
used after android 5.0 came out, but uses Android Runtime (ART) instead, which is not a VM.
DVM (Dalvik VM) is good because it offers portability (it is used to run Java bytecode),
security, and memory management.

Application Framework: uses libraries to offer components for developers, it offers two types
of services:
● Core Platform services: services are applications which run in the background. These
contain essential services:
○ Activity manager: manages the life cycle of activities, and the navigation pile
stack.
○ Package manager: used by Act Man to load information from the .apk
○ Window manager: which window must appear next to another.
○ Resource manager: images, files, audios, etc.
○ View system: graphical components.
● Hardware services: access to hardware API.
○ Telephony services: manages access to telephonic services (GSM, 3G, etc.)
○ Location services: access to GPS interface.
○ Bluetooth services: access to interface.
○ Wi-Fi services: same.
○ USB services: same.
○ Sensor services: access to sensors.
Application & widgets: group of android apps.

Development environment:
Whether it be Eclipse + JDK + SDK, or Android studio, which is based on IntelliJIDEA, it
allows for Koten/Java/XML files and graphic visualization. It consists of two repositories.
First one: App:
A file tree to organize the structure, and simplify the dev process, contains:
● Manifest: XML file describing the app and its components, such as activities, services,
etc.It also specifies various options such as: the hardware requirements, certain
security settings, icon, file’s name, etc. It can be considered to be the application’s ID
card, and that which authorizes activities to run.
● Java/Kotlen: contains Source code.
● Res: resources such as images, GUI views, etc.

Second one: Gradle Scripts:


Gradle is a tool that automates the build operations of a Java application, to generate the APK
file located in the bin directory, and can be executed on a device or VM.

The chapter began with an overview of embedded systems, which are fundamental to mobile
operating systems. It then detailed Android's inception, versions, and architecture. The final
section focused on Android development environments, methods, and the structure of an
Android Studio project. The upcoming chapter will delve into the essential elements of
mobile applications, crucial for their construction.

Chapter 2: advanced concepts


Learning technologies, improving UXs (user experiences), innovating, and understanding
resources, activities, and GUIs to design high quality apps,

Activities:
*Usually, all apps follow a similar structure, with each window serving a specific function
called “activity”. An activity is what links between the User Interface (UI) and the backend
code, you can tell that the activity has changed if the UI completely changes, so for us: the
activity is the window we are visualizing, e.g., the UI change when you click on the return
button, or a youtube video.
*Activities also contain information about the current state of the application, known as the
“context”, which connects the OS with the activities within the app.
*Interface = {Layouts + Views}, layouts define the structure and layout (linear layout, relative
layout, etc.) to organize Views within an activities and fragments. Views are the UI interactive
components, e.g., buttons.
Activity Status:
It can vary based on priorities and system resources. When an application is launched, it
occupies the top of the activity stack (la pile), and the visible activity is the one the user
interacts with. If a new activity with higher priority takes the top of the stack, replacing the
current activity, then the old activity will reappear when the activities above it are stopped.
An activity can exist in three states primarily distinguished by their visibility:
1. Active: The activity is at the top of the stack and fully visible. It represents the current
application, receiving the user's full attention and being fully usable.
2. Paused: Users do not directly interact with the activity. Typically, it remains partially
visible (i.g., when a notification arrives, a semi-transparent window appears in front
of the current activity to show the message content and allow a response). At this
stage, the application loses focus to the one above it. To regain focus, the user must
dismiss the top application, enabling direct interaction with the activity. If memory is
needed, the system may eventually close the application.
3. Stopped: This means the activity is completely invisible on the screen, and the
application no longer holds focus, and the system keeps a small portion of its memory
to retain its state in case of re-opening.

Control center (hadik l3fsa ta3 notification etc) is a part of the OS, it may be a fragment.

Activity Life Cycle:


By default, an
activity does not
have direct
control over its
own state. The
lifecycle is
governed by
interactions with
the system and
other
applications.

onCreate(): called when the activity starts, it initializes the views and starts background
tasks, taking a Bundle as a parameter that contains the previous state of the activity. A bundle
is a container for a collection of data, typically used for passing data between activities.
onStart(): Indicates the effective start of the activity, it can be called by the onRestart method.
(consult the figure)
onResume(): it runs right after onStart(), or after a short pause, it executes necessary
operations for the activity to function again, initializes the variables and listeners. These
operations should be paused during the onPause method and resumed during subsequent
onResume() method. Note that it uses the Bundle when resuming.
onPause(): If another activity comes to the foreground, the current activity is paused, and just
before onPause, a call to the onSaveInstanceState() method is made to save important
information.
The onPause() actually halts (stops) all operations of the activity if it is not visible, and
corresponds to a call to onResume if the activity becomes visible again.
Passing to Stopped Status: a call to the onStop method, and halts all remaining operations.
What's after the Stopped Status: the act can be resumed with onRestart followed by the
normal lifecycle, or can be terminated with a call to the onDestroy(), which halts all
remaining operations, closes database connections, threads, open files, etc. It’s a killer.

Resources:
refers to any element or asset used in a system, program, or application, it takes many forms
and serves different purposes, i.g., hardware, files, source code, libraries and functions, data,
network, etc.

GUI: Graphical User Interface


Graphical contact point between a computer system and a user.

Key Aspects:
Elements, their interactivity (interactions), their reactivity (speed), their disposition
(coherent and logical disposition), and aesthetic look.

Intent:
A messaging object for requesting actions or broadcasting events. It facilitates
communication between different components and the system, allowing for launching
activities, interacting with other apps, and exchanging data seamlessly.

Messages & Actions:


Intent messages originate from Android, other apps, or services, informing active applications
of events like receiving SMS or GPS updates. Internet’s role is facilitating communication,
allowing apps to offer or request services and data flexibly.

Main Usages:
Explicit Intent: use it to launch specific components within your app by explicitly specifying
the class name.

Implicit Intent: use it to perform actions without explicitly specifying the component to start,
Android system automatically selects the appropriate component.
Intent with data: Use: Allows transmission of data between application components.

Implicit Intent for Image Selection: Opens an application enabling the user to select an image.

Fragments:
A fragment, unlike an activity, represents only a portion of an application's user interface. It
can be considered as a reusable component that can be integrated into different activities to
create a flexible and dynamic user interface [during runtime], it can be static as well.

Characteristics:
Reusability (can be integrated in different activities, without redundancy issues), integration
flexibility, ease of communication amongst each other and with the app’s components
(flexibility ++), and independent life cycle: precise state control and optimal resource
management.

Communications:
Two main methods: through the host activity by using it as a mediator, this method is useful
for handling interactions that involve multiple fragments or require coordination between
them but do not need direct communication between the fragments themselves. I.g., when
fragment A is selected, the item’s (i.g., the T-Shirt) details are displayed in fragment B.
Direct communications: good for specific and fast interactions.

Usage:
Pure XML: Right click the package folder -> New -> Fragment => Fragment (blank), name it,
and finish. Now head to the fragment’s XML file, and customize your fragment, adding text
and buttons and whatnot. Now go to the fragment’s Java file, implement the algorithms. Now
go to the main_activity.xml file, and add your fragment using
android:name=“com.example.myapp.[FragmentName]”, with FragmentName being identical to
the fragment’s java file.

Using java: start by creating the fragment etc, then importing


import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;,
Then instancing it:
MyFragment myFragment = new MyFragment();,
then getting a support fragment manager:
FragmentManager fragmentManager = getSupportFragmentManager();, which is more
compatible with older Android versions, it allows you to do many fragment operations
seamlessly.
FragmentTransaction fragTransa = fragmentManager.beginTrasaction();
now add the fragment to your activity layout:
transaction.replace(R.id.[fragment_container_id], myFragment);,
finally, commit the changes: transaction.commit();,

BackStack:
Use BackStack to allow users to return using the return button, enhancing the UX:
fragmentTransaction.addToBackStack(null); use this post replacement / addition / deletion.

Barre d’Action:
Located at central top, for frequently done actions, define it using Toolbar element:

You can display items on the toolbar like so:


<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/action_search" <- this one to add an ID
android:icon="@drawable/ic_search" <- icon
android:title="Search" <- subtitle
android:showAsAction="ifRoom" /> <- show if there’s enough space, else, use the
. overflow menu, means it will show three dots to show more options.
</menu>
And display a return button on the toolbar:
getSupportAcionBar().setDisplayHomeAsUpEnabled(true);.
You can set up tabs in the toolbar, tabs belong to the same mother activity, but hold and
display different sections of it.
You can set colors using <item name=“colorPrimary”>#hexcode</item>. And define its layout
using app:actionViewClass=”path/to/aView”.

Animations:
Dynamic visual techniques to enhance the UX. it can be a transition, commonly used to
transition activities, we have the transition (fade in/out or slide in/out or drop in/out):

A simple rotation:

Scaling (Echelle):
Fading (fendu) animation:

Persistence:
1) Activity’s data persistence: Saves the user’s journey through the app, and maintains
the UI status in case of his return.
2) Key=value: using it to store preferences, configuration, and acts’ status in a file.
3) File System usage: since files are the primitive way of storing in Android, external or

key=value 🤷🏻‍♂️
internal storage drives can be used. Manich fahem the diff between it and the

4) Using SQLite DB.

Activity Data Persistence:


Done via life cycle. The onSaveInstanceState(); saves the activity’s data as a Bundle data
type before destroying it (i.g., return button click), and passes the Bundle to the onCreate();
and onRestoreInstanceState(); to re-establish the UI when the activity is created/restored.
This persistence allows the user to walk back the path he has taken to get to X activity.
However, the toolbar return button functions differently, as it takes the activity back to where
the developer programmed it to take.

Préférence Partagées:
A mechanism to store and restore data using key=value pairs, used on preferences, config,
etc. of simple data.
Goal: a simple and fast mean of storing lightweight data, with easy access to this data.

To restore:
Files:
Code Source:
Including Java/Kotlen files, or Swift/Objective-C for iOS, which define the app’s comportment.
Assets (fichiers de resources):
Static files such as images, icons, config files, etc. in a “res” folder in android or “Assets” in
iOS, and integrated in the application while executing.
Layouts (mise en page): XML
Define the layout’s structure and representation, and element disposition.
Manifest files:
AndroidManifest.xml, or Info.plist for iOS, contain crucial information such as the needed
permissions, components, services, etc.
Local Data files:
Can be an SQLite DB, or shared preferences files, or a totally different format specific for the
application.
Config files:
Such as properties files, JSON config files, etc. They are usually used to parametrize the app’s
behavior.
Logs (journal):
Generated while executing, good for debugging and monitoring.
APK, IPA:
When the app is developed, it is gathered in an installation file (APK for android and IPA for
iOS).
Certificates and keys files:
Remember security? Asymmetric algorithms’ keys and certification? Exactly. To secure the
network communications with secured services.

XML:
- I skipped many slides-
They are used for: behavior configuration, data exchangement, and as a universal language.
TP1:
New project -> Empty Activity -> name, package name, save location, language, minimum
SDK to use -> DONE! The IDE will have the project’s tree on the left, and the code on the
main part of the screen, along with the tabs and some information at the bottom.
Project creation results in an activity + a screen, showing “hello world!”, you can compile it
with the menu: Build -> make project, ctrl+f9, or the hammer green button. You shall see a
notification at the bottom “Gradle build running”.
You can run it by Run->run app, Maj+F10, or green play button. If you run before compiling, it
will compile first then run, make sure you've connected your phone to run it or a VM, which
will consume resources.
To set up a virtual machine, click on the phone icon at the top bar -> create device -> choose
an Android Virtual Device -> OS version -> finish. Now re-run.
It has an execution console, called logcat, at the bottom.
If you change the .java file, you should update the manifest file, this line particularly:
<activity android:name=".NewMainActivity">
Texts are found in the XML file in a <TextView/>,

Variable creation and linking files:


When you create a variable in res/values/string.xml file, for ex:
<string name="app_name">MyApp</string>,
You must link it in the main_activity.xml like so:
<TextView
android:id="@+id/welcomeTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/welcome_message" />,
See how the name is equal to android:text, it’s somewhat similar to other resources.

Translate:
Can be done manually in the res/values/string.xml file, and create additional files:
values-fr/string.xml, values-en/string.xml, values-du/string.xml for german. Or with the GUI by
right clicking on the string.xml file -> Open Translations Editor -> adding a language -> giving
translated texts.

Icon:
Right click on “app” directory -> New -> Image Asset -> configure your icon’s settings & select
an image and there you go :) save n leave, actually don’t leave, go to AndroidManifest.xml ->
locate the <application>, find android:icon attribute, change this to your icon’s name
without the extension: android:icon="@drawable/new_icon", you will choose the name when
changing the icon.
If you delete an icon, or all icons, android studio (AS) will automatically update
AndroidManifset.xml for you, usually, but you can double check that the android:icon is
pointing towards the right element.
NOTE: from the official website: Jan 3, 2024 — The name can contain lowercase characters,
underscores (_), and digits only. Trim - To adjust the margin between the icon graphic and
border in the ...
First TP is completed successfully.
TP2:
Every seen element is called a view, which is a location expressed using left and top
coordinates, and length and width dimensions, in density pixel (dp), which is the number of
pixels within a given area on a display screen, higher DP = more clarity.
It can be: texts, inputs, buttons, or a ViewGroup such as that contain views and manage the
layout.

ViewGroup:
Containers and sometimes layout managers, they are the parents for child views
ConstraintView: create complex layouts by defining relationships (constraints) between views
[or screen border].
ScrollView: scrolls down if the child element is bigger than the screen, can have exclusively
one child.
RecyclerView: same as scrollView, but allows for dynamic child addition and deletion, which
optimizes the performance by reducing the total views, but it requires a layout manager.

Note: ViewGroups can be nested.

LinearLayout: groups childs vertically or horizontally.


RelativeLayout: views are located relatively to each other (similar to ConstraintView).
TableLayout: children are located in lines and columns.
FrameLayout: reserves a zone for a child, can have multiple children, its length is the total
length of the children, children are organized in a stack, with the last one being on top.
GridLayout: say Hello to Arrays :p

LinearLayout example:

It’s important to understand the hierarchy.


There’s a graphical way to visualize the layout, going to activity_main.xml , selecting “design”
at bottom left, you drag and drop elements, give attributes at top right.

ToolBar:

1) select design / blueprint / both


2) Rotate visual screen
3) Preview device.
4) Displayed Android version in the preview device.
5) To select a theme, including colors, fonts, and styles without navigating the XML file.
6) This list only displays the languages available in the res/values/string.xml file.
For the ConstraintLayout toolbar:

1) Select “show constraints” + “show margins”.


2) Suggests connection and constraints generation, you only have to slide the view, and it
provides real time feedback and suggestions.
3) Remove all constraints and connections.
4) Quickly ensure that all views are properly constrained, it is automatic, similar to “2” in
purpose, but functions differently, as it does not suggest, but applies directly.
5) Default margin width.
6) Pack or expand: the first one will adjust the container’s layout to fit the content more
tightly, or expand the content to accommodate its content more comfortably.
7) Automatically align the left edges of selected views.
8) Horizontal or vertical directing guidelines.
9) Zoom.

everything should be clear, except the fourth,


which is a base guideline: the base of the text,
can be used to align views which contain text
(TextView with Button), by hovering over one
of the views, clicking the button that appears,
dragging the handle to meet the second
element’s baseline. Or do a right mouse click.

Those constraints which you define will be translated to XML code.

Attributes:
You will see this:
1) Layout_height,
2) Layout_width
3) Close attributes.
The 8 indicates the margin.
The first two can have three values:
wrap_content means that the layout’s size will
adapt to its content., and match_constraint so
the child element will be made to fit the parent,
and a defined fixed size in Density Pixels.
Tip: When changing layout_width, if no
dimension is specified, it defaults to zero, similar
to match_constraint, the UI element can expand
to meet the specified constraints and margins.

XML version:
Attributes are set in this format:<android: attr_name=“value”, if the value is a resource then:
<android: attr_name=“@resource”, i.g., android:background="@color/myBackgroundColor,
noting that the bg color is already defined. To refer to a View’s attribute: android:
id=@+id/attr_name, the @+id means create a new resource of type ID called attr_name, and
assign it to the View element, then use this ID to refer to the resource.
To refer to a view, just remove the “+” sign.

Layout Variants:
You can rotate the screen to visualize it in that mode, or select another device. To make a
variation: drop down the rotation icon button -> Create Landscape Variation, this will create a
land/activity_main.xml, a variant for the landscape orientation, you can now modify this view
and the portrait orientation will stay intact. You can see `res/layout/activity_main.xml(land)`
underneath the old one.
To create a device variant (for tablet or whatnot): Orientation for preview -> Create a tablet
variant (wella 3fsa hka) then get going. You will find new files just like before.

Linear positioning in LinearLayout:


LinearLayout must have these attributes: android: layout_width, android: layout_height,
android: orientation, the first two can have these values: match_parent fills the parent by
adjusting the children, and wrap_content adjusts to fit the content, or a “dp” specifies fixed
size. Orientation can be horizontal or vertical.
Another attribute for this layout: android: gravity, this attribute affects the position of the
content within the ViewGroup, for example: android: gravity=“center_[horizontal |
vertical]”, the child will be centered horizontally, based on the parent’s position.
android: padding[Top|Bottom|Left|Right|Start|End], padding is the space between the
beginning of the View, and the beginning of the content inside of it, like the difference
between your skin and your bone. The first four are clear, the last two are useful for dynamic
layouts that change based on the device’s language direction, i.g., in English: paddingStart and
paddingEnd are equal to paddingLeft and paddingRight, but it’s the opposite for Arabic.
The area between the dashed line and the solid line
is the padding

Relative Layout:
It uses these attributes: android; layout_[ toLeftOf | toRightOf | centerHorizontal |
center_vertical | align_parentTop | align_parentBottom]=“@ID_of_some_element”, you
say that this element’s left or right of @ID element, or horizontally/vertically regarding the
parent, or attach the top/bottom of this element to the top/bottom of its parent, respectively.
It has others, the teacher said: voir le cours, however, these were not mentioned, I assume
that this is chapter 4+ ?

TP3: Go back to the fragment part :), or click here.


However, I will add some notes here that were not included in the PDFs…
Add <intent-filter> to define an activity as the launcher activity.
Use this myButton.setOnClickListener(new View.OnClickListener(){// Code}) to program
the button to react to clicks.
Use import android.content.Intent; to import intent.
Use this to define a button: Button myButton = findViewById(R.id.myButton);
Use this to start a new activity using intent:
Intent intent = new Intent(this, NouvelleActivite.class);
startActivity(intent);
Use this tag to define an activity in the manifest file: <activity>
You can apply onSaveInstanceState() on fragments.
SQLite est un moteur de base de données relationnelle.

You might also like