Professional Documents
Culture Documents
Intro in Android
2021
Intro in Android
Contents
FACULTATEA DE ELECTRONICĂ, TELECOMUNICAŢII ŞI TEHNOLOGIA INFORMAŢIEI
1. What is Android
2. Android Studio
UNIVERSITATEA TEHNICĂ “GH. ASACHI” DIN IAŞI
3. Programming languages
4. Android Arhitecture
5. Gradle
❖It was first developed by Android Inc, a company located in California, USA, which
UNIVERSITATEA TEHNICĂ “GH. ASACHI” DIN IAŞI
❖The first phone with Android OS was HTC Dream, launched in 2008.
❖Since 2008, Android has been developed into several versions. Their code names were
in alphabetical order and each name was representing a cake. For example, 4.4 was
named KitKat, 7.0 was named Nougat, 9.0 was named Pie. From version 10, which was
launched in September 2019, Google started to name the versions just with numbers
Google for developing Android Applications, available for free, based on Intellij Idea, an
❖The first stable version of Android Studio was launched in December 2014 and has
replaced Eclipse (with Android Development Tools(ADT)) as the primary IDE for Android
development.
❖Android Studio offers full support for developing Android applications, which includes
the possibility to debug and run the applications on an Android Virtual Device(AVD) or
on a real device.
Intro in Android
Programming languages
❖The main programming language for developing Android Applications is Java. Android
FACULTATEA DE ELECTRONICĂ, TELECOMUNICAŢII ŞI TEHNOLOGIA INFORMAŢIEI
❖Which each Android version release, a new API version is released too and becomes
❖Java code is run by a virtual machine called Android Runtime(ART), which replaced
Dalvik.
❖Another support programming language is C/C++. The low-level layers, for example
Android Architecture
Intro in Android
Source of photo:
https://developer.android.com/guide/platform
Intro in Android
Gradle
❖ The tool used by Android Studio to build an Android Project is Gradle.
FACULTATEA DE ELECTRONICĂ, TELECOMUNICAŢII ŞI TEHNOLOGIA INFORMAŢIEI
❖ Gradle is a specialized tool for building applications and projects, independent to the
❖ The build with Gradle can be launched from Android Studio menu or from console.
Intro in Android
Android Device Types
❖ Android applications extended from Smartphones and Tablets to:
FACULTATEA DE ELECTRONICĂ, TELECOMUNICAŢII ŞI TEHNOLOGIA INFORMAŢIEI
– Android Things
– In “Phone and Tablet” tab, select “Empty Activity” and click Next
UNIVERSITATEA TEHNICĂ “GH. ASACHI” DIN IAŞI
• Click Finish
UNIVERSITATEA TEHNICĂ “GH. ASACHI” DIN IAŞI
Project structure
❖ Structure of the Empty Activity project:
Intro in Android
Intro in Android
Project structure>MainActivity
❖ An activity represents one screen of the application’s user interface. When an “Empty
FACULTATEA DE ELECTRONICĂ, TELECOMUNICAŢII ŞI TEHNOLOGIA INFORMAŢIEI
Activity” project is created, Android Studio creates a default activity class, named
MainActivity, and an xml, named activity_main.xml, that describes the content of
the user interface(the layout) of that activity.
UNIVERSITATEA TEHNICĂ “GH. ASACHI” DIN IAŞI
MainActivity.java
activity_main.xml
Intro in Android
Project structure>AndroidManifest.xml
❖ In app>manifests>AndroidManifest.xml, in tag <activity>, it is specified the Activity
FACULTATEA DE ELECTRONICĂ, TELECOMUNICAŢII ŞI TEHNOLOGIA INFORMAŢIEI
interface(ex. button, input text) is identified by a tag, which has several attributes, like
id, name, text, width, height, etc.
UNIVERSITATEA TEHNICĂ “GH. ASACHI” DIN IAŞI
A TextView(label)
with with text
“Hello World!”
Intro in Android
Building an application
❖ In order to build(compile) an application, one can select menu Build->Make Project or
FACULTATEA DE ELECTRONICĂ, TELECOMUNICAŢII ŞI TEHNOLOGIA INFORMAŢIEI
Rebuild Project, or the Build Icon. The result is displayed in the Build Output Window
Build Icon Build Menu
UNIVERSITATEA TEHNICĂ “GH. ASACHI” DIN IAŞI
Build Window
Intro in Android
Running an application
❖ An application can be run in two environments:
FACULTATEA DE ELECTRONICĂ, TELECOMUNICAŢII ŞI TEHNOLOGIA INFORMAŢIEI
– On a real device
UNIVERSITATEA TEHNICĂ “GH. ASACHI” DIN IAŞI
Intro in Android
Adding a virtual device AVD Manager
❖ Android Virtual Device(AVD) Manager can be accessed from Tools->AVD Manager
FACULTATEA DE ELECTRONICĂ, TELECOMUNICAŢII ŞI TEHNOLOGIA INFORMAŢIEI
❖ From AVD Manager, in order to add a new Virtual device, one can select “Create
In order to enable it, go to Settings>About phone and tap “Build number” seven
times.
❖Turn On also Stay Awake, in order to keep the screen On while testing the
application.
❖ After USB debugging is enabled, the next step is to connect the phone to the
❖When the phone is connected, the real device should be available in the Run menu
❖Selecting the real device will start the application on the real device.
Intro in Android
Running the app
❖ The device on which the application shall run can be selected from the device list. In
FACULTATEA DE ELECTRONICĂ, TELECOMUNICAŢII ŞI TEHNOLOGIA INFORMAŢIEI
the above picture are listed Pixel XL(an AVD) and a Samsung phone, which was
❖In order to run the application, the green triangle button shall be selected or to select
Run>Run menu.
Intro in Android
Editing User Interface
❖The user interfaces are defined in the layout folder, as xml files. The xmls can be
FACULTATEA DE ELECTRONICĂ, TELECOMUNICAŢII ŞI TEHNOLOGIA INFORMAŢIEI
edited directly, in Code view, or by a graphical interface, in Design view. Switch between XML
view, Design View or
Design Area Split View
Area to edit the xml
UNIVERSITATEA TEHNICĂ “GH. ASACHI” DIN IAŞI
Intro in Android
Editing User Interface>Design View
FACULTATEA DE ELECTRONICĂ, TELECOMUNICAŢII ŞI TEHNOLOGIA INFORMAŢIEI
Different UI elements Enabling the view of different Layout view The attributes of the
that can be added to elements(Constraints, selected UI element
the layout Margins)
UNIVERSITATEA TEHNICĂ “GH. ASACHI” DIN IAŞI
Intro in Android
Example: Adding UI elements and drawing constraints
❖Delete the “Hello World” TextView, that was by default added by Android Studio.
FACULTATEA DE ELECTRONICĂ, TELECOMUNICAŢII ŞI TEHNOLOGIA INFORMAŢIEI
❖ Add constraints by dragging lines from the bullets of each of the sides of the
The four constraints
TextView to the sides of the layout that define how the
element is placed
relative to the other
elements(the layout, in
this case)
to “Email Address”
UNIVERSITATEA TEHNICĂ “GH. ASACHI” DIN IAŞI
❖Change the width or the height attributes accordingly, in case the new text doesn’t fit
properly.
Intro in Android
Exercise>Adding UI elements
❖ Add a PlainText to the right of the textViewEmail added previously:
FACULTATEA DE ELECTRONICĂ, TELECOMUNICAŢII ŞI TEHNOLOGIA INFORMAŢIEI
- Draw the four constraints. The left constraint shall be linked to textViewEmail
UNIVERSITATEA TEHNICĂ “GH. ASACHI” DIN IAŞI
element, while the other to the top, bottom and right sides of the layout
Intro in Android
Exercise>Adding UI elements
❖ Add a Button below the textViewEmail:
FACULTATEA DE ELECTRONICĂ, TELECOMUNICAŢII ŞI TEHNOLOGIA INFORMAŢIEI
- Draw the four constraints. The top constraint shall be linked to textViewEmail
UNIVERSITATEA TEHNICĂ “GH. ASACHI” DIN IAŞI
element, while the other to the left, bottom and right sides of the layout
UNIVERSITATEA TEHNICĂ “GH. ASACHI” DIN IAŞI
Exercise>Adding UI elements
❖Run the application on an AVD or on a real device
Intro in Android
Intro in Android
Bibliography
❖ “Hello, Android”, Ed Burnette, 2015
FACULTATEA DE ELECTRONICĂ, TELECOMUNICAŢII ŞI TEHNOLOGIA INFORMAŢIEI
❖https://developer.android.com/guide/platform
UNIVERSITATEA TEHNICĂ “GH. ASACHI” DIN IAŞI
❖https://www.vogella.com/tutorials/android.html