MDAD 3 - Basics of UI Applications

Android
Basics of UI Applications
Bibliography
1. Wallace Jackson, Android Apps for Absolute
Beginners, Apress, 2017
2. Peter Späth, Learn Kotlin for Android
Development, Apress 2019
3. Android Application Fundamentals,
http://developer.android.com/guide/topics/f
undamentals.html
2
Let’s recap
• Android
– OS
– Platform
– Kernel
– User space libraries
– Hardware Abstraction
Layer
– Dalvik / ART
– Android Libraries
– Applications
• Android Applications
– Types
– Security
3
Contents
• Containers
• Resources
• Build GUI with XML
• Intents
• Manifest
• Toast
4
Android Schematics
5
Task (UI Application)
• Runs in one process
– usually!
– There are exceptions
• Stack of activities
• Root activity
– Add
• Display
• push
– Remove
• Hide
• pop
– Activities from other
applications
6
Important Functions
• Clasa Activity
– void onCreate (…);
– void onStart (…);
– void onRestart (…);
– void onResume (…);
– void onPause (…);
– void onStop (…);
– void onDestroy (…);
• Must call the parent
overridden functions
• super.onCreate (…);
– …
7
Storing and loading of the status
• Store
– void onSaveInstanceState (Bundle state)
• Load
– void onLoadInstanceState (Bundle state)
– void onCreate (Bundle savedInstance)
8
Components (Widgets)
• Extend View
• Placed on an Activity
– Static
• TextView
• ProgressBar
• ImageView
• …
– Dynamic
• Button
• EditText
• CheckBox
• RadioButton
• SeekBar
• Spinner
• Gallery
• MapView
• ListView
• …
9
Container
• View
– Contains other Views
– Layout
• Types (outdated)
– LinearLayout
– RelativeLayout
– TableLayout
– ScrollLayout
• They are used
combined
10
Container Types
LinearLayout RelativeLayout
11
Container Types
TableLayout AbsoluteLayout
12
Resources
• res folder (from the source)
• Images
– drawable -_dpi
• ldpi
• mdpi
• hdpi
• UI
– layout
• Constants
– Values
• strings.xml
• Raw
– Unmodifiable resources
13
Automatic resources in Java code
• Drawable
– Images
– R.drawable.name
• R.drawable.icon
• R.drawable.img1
• R.drawable.img2
• Layout
– Containers
– R.layout.name
• R.layout.main
• R.layout.people
14
Automatic resources in XML
• Drawable
– Images
– @drawable/name
• @drawable/icon
• @drawable/img1
• @drawable/img2
• Layout
– Containers
– @layout/name
• @layout/main
• @layout/people
15
Constructing the GUI with XML
• Complex component
• Simple code
• No Java code
• In the Activity code
– this.setContentView (R.layout.name);
16
GUI XML example file
17
GUI XML example file
• xmlns:android
– Only the root component
– mandatory
• android:layout_width
• android:layout_height
– mandatory
– Values
• fill_parent
• wrap_content
• match_parent
• n px
• n cm
18
GUI XML example file
• android:id
– Usage of the component
in the Java code
– @+id/name
• R.id.name
– Example
• @+id/button1
– R.id.button1
19
GUI XML example file
• android:id
– Usage of the component
in the Java code
– @+id/name
• R.id.name
– Example
• @+id/button1
– R.id.button1
20
GUI XML example file
XML Java Code
21
Menu
• MENU (soft) button press
• Events
– public boolean
onCreateOptionsMenu (Menu
menu);
– public boolean
onOptionsItemSelected(MenuItem
item);
• Adding a menu
– menu.add (…);
22
Menu Example
23
Menu using XML
XML (res/menu/meniu.xml) Java Code
24
Menu using XML
• XML (res/menu/meniu.xml)
25
Menu using XML
• Java Code
26
Intents
• Intent
– A component that wants
something
• Generates events
– Phone call
– Send sms
• Object
27
The intent is described by
• Action
• Data
• Category
• Type
• Component
• Extras
28
Action
• Desired action
– Call
– Send sms
– Open document
– Edit document
– Start an activity
• String
– “android.intent.action.MAIN”
– “android.intent.action.VIEW”
29
Action example
• ACTION_MAIN
• ACTION_VIEW
• ACTION_EDIT
• ACTION_PICK
• ACTION_CHOOSER
• ACTION_GET_CONTENT
• ACTION_DIAL
• ACTION_CALL
• ACTION_SEND
• ACTION_SENDTO
• ACTION_ANSWER
• ACTION_SEARCH
• ACTION_WEB_SEARCH
• …
30
Exampe of informative action
• ACTION_TIME_TICK
• ACTION_TIME_CHANGED
• ACTION_TIMEZONE_CHANGED
• ACTION_BOOT_COMPLETED
• ACTION_PACKAGE_ADDED
• ACTION_PACKAGE_CHANGED
• ACTION_PACKAGE_REMOVED
• ACTION_PACKAGE_RESTARTED
• ACTION_PACKAGE_DATA_CLEARED
• ACTION_UID_REMOVED
• ACTION_BATTERY_CHANGED
• ACTION_POWER_CONNECTED
• ACTION_POWER_DISCONNECTED
• ACTION_SHUTDOWN
31
Data
• Associated data
• Usually an URI
– tel:123
– content://contacts/…
– File:///sdcard/...
32
Category
• Defines better the action
– CATEGORY_LAUNCHER
– CATEGORY_ALTERNATIVE
– CATEGORY_DEFAULT
• Additional information
• Optional
• String
– "android.intent.category.MAIN“
– "android.intent.category.ALTERNATIVE"
33
Category example
• CATEGORY_DEFAULT
• CATEGORY_BROWSABLE
• CATEGORY_TAB
• CATEGORY_ALTERNATIVE
• CATEGORY_SELECTED_ALTERNATIVE
• CATEGORY_LAUNCHER
• CATEGORY_INFO
• CATEGORY_HOME
• CATEGORY_PREFERENCE
• CATEGORY_TEST
• CATEGORY_CAR_DOCK
• CATEGORY_DESK_DOCK
• CATEGORY_CAR_MODE
34
Type
• Data type
– It is generally determined in
• file:///sdcard/poze/poza.jpg
– It has priority over
• Optional
• String
– “image/jpg”
– “contacts/contact”
35
Component
• Mentions the specific
destination component
• Optional
• Start/Stop
– Activities
• startActivity (…)
• finishActivity (…)
– Services
• startService (…)
• stopService (…)
36
Extras
• Extra data
• Bundle
– putExtra ()
– getStringExtra ()
– getIntExtra ()
– getBooleanExtra ()
– …
37
Usage
• Functions which emit intents
– void startActivity (Intent i)
– void startService (Intent i)
– void sendBroadcast (Intent i, String permission)
• The system searches for the appropriate
component
– Intent Resolution
38
Search for the activity
• Filter arguments
– ACTION
– TYPE (usually extracted from DATA)
– CATEGORY
• Determined
– Determines the appropriate component
– Determines the appropriate components list
39
IntentFilters
• Components that declare filters
– Activities
– Services
– BoradcastReceivers
• Windows equivalent
– File association
• In AndroidManifest.xml
40
Example
The applications menu asks for a list of components that respond to
Action: ACTION_MAIN
Category: CATEGORY_LAUNCHER
41
Exemple (2)
42
Exemple (3)
43
Manifest
AndroidManifest.xml
– Declare components (Activities, Services, etc)
– Declare permissions
44
Starting of an activity
• context.startActivity (Intent intent);
Intent starter = new Intent (context,
ActivityClass.class);
context.startActivity (starter);
45
Stopping an activity
• context.finishActivity (Intent intent);
– Another component wants to stop the Activity
• finish ();
– The Activity stops itself
Intent starter = new Intent (context,
ActivityClass.class);
Context.finishActivity (starter);
46
Toast
• Display notifications
– Short
• Toast.LENGTH_SHORT
– Long
• Toast.LENGTH_LONG
• Toast
47
Conclusions
• Task
– A stack of activities
• Intents
• Manifest
– Declare activities
• Automatic Resources
– Drawable
• R.drawable.nume
• @/drawable/nume
– Layout
• Fișiere XML
• R.layout.nume
• @/layout/nume
• Toast
– Display messages
48
Keywords
• Task
– Stack
• Activity
– Lifecycle
• Containers
– Layouts
– LinearLayout
– TableLayout
– RelativeLayout
– GridLayout
• Toast
• XML GUI
• Menu
• Manifest
• Components
– Static
• TextView
• ProgressBar
• ImageView
• …
– Dynamic
• Button
• EditText
• CheckBox
• RadioButton
• SeekBar
• Spinner
• Gallery
• MapView
• ListView
49
Quenstions
50
1 of 50

Recommended

MDAD 2 - Introduction to the Android Framework by
MDAD 2 - Introduction to the Android FrameworkMDAD 2 - Introduction to the Android Framework
MDAD 2 - Introduction to the Android FrameworkAlexandru Radovici
688 views40 slides
Embedded Android Workshop by
Embedded Android WorkshopEmbedded Android Workshop
Embedded Android WorkshopOpersys inc.
2.7K views190 slides
lập trình di động by
lập trình di độnglập trình di động
lập trình di độngtruong le hung
4.6K views29 slides
Đồ án tốt nghiệp Xây dựng ứng dụng fastfood trên nền android by
Đồ án tốt nghiệp Xây dựng ứng dụng fastfood trên nền androidĐồ án tốt nghiệp Xây dựng ứng dụng fastfood trên nền android
Đồ án tốt nghiệp Xây dựng ứng dụng fastfood trên nền androidlaonap166
27K views35 slides
AID in android by
AID in androidAID in android
AID in androidChien-Ming Chou
3.4K views7 slides
Intro To Android App Development by
Intro To Android App DevelopmentIntro To Android App Development
Intro To Android App DevelopmentMike Kvintus
6.4K views35 slides

More Related Content

What's hot

MongoDB.pptx by
MongoDB.pptxMongoDB.pptx
MongoDB.pptxDuyThnh28
36 views31 slides
Flutter by
FlutterFlutter
FlutterShyju Madathil
1.2K views16 slides
Tạo mã độc trên kali linux để xâm nhập android (mạng lan ) by
Tạo mã độc trên kali linux để xâm nhập android (mạng lan )Tạo mã độc trên kali linux để xâm nhập android (mạng lan )
Tạo mã độc trên kali linux để xâm nhập android (mạng lan )Trọng An
1.6K views13 slides
10 tk3193-ids by
10 tk3193-ids10 tk3193-ids
10 tk3193-idsSetia Juli Irzal Ismail
2.1K views27 slides
Building a Successful Internal Adversarial Simulation Team - Chris Gates & Ch... by
Building a Successful Internal Adversarial Simulation Team - Chris Gates & Ch...Building a Successful Internal Adversarial Simulation Team - Chris Gates & Ch...
Building a Successful Internal Adversarial Simulation Team - Chris Gates & Ch...Chris Gates
2.8K views73 slides
Docker Forensics by
Docker ForensicsDocker Forensics
Docker ForensicsJoel Lathrop
1.4K views26 slides

What's hot(20)

MongoDB.pptx by DuyThnh28
MongoDB.pptxMongoDB.pptx
MongoDB.pptx
DuyThnh2836 views
Tạo mã độc trên kali linux để xâm nhập android (mạng lan ) by Trọng An
Tạo mã độc trên kali linux để xâm nhập android (mạng lan )Tạo mã độc trên kali linux để xâm nhập android (mạng lan )
Tạo mã độc trên kali linux để xâm nhập android (mạng lan )
Trọng An1.6K views
Building a Successful Internal Adversarial Simulation Team - Chris Gates & Ch... by Chris Gates
Building a Successful Internal Adversarial Simulation Team - Chris Gates & Ch...Building a Successful Internal Adversarial Simulation Team - Chris Gates & Ch...
Building a Successful Internal Adversarial Simulation Team - Chris Gates & Ch...
Chris Gates2.8K views
Kiem thu phan mem by TIen Le
Kiem thu phan memKiem thu phan mem
Kiem thu phan mem
TIen Le8.1K views
Cài đặt lập trình Android trên Netbeans by Nguyễn Anh
Cài đặt lập trình Android trên NetbeansCài đặt lập trình Android trên Netbeans
Cài đặt lập trình Android trên Netbeans
Nguyễn Anh1.9K views
Snort it-slideshares.blogspot.com by phanleson
Snort it-slideshares.blogspot.comSnort it-slideshares.blogspot.com
Snort it-slideshares.blogspot.com
phanleson3.4K views
Purple Team Exercise Hands-On Workshop #GrayHat by Jorge Orchilles
Purple Team Exercise Hands-On Workshop #GrayHatPurple Team Exercise Hands-On Workshop #GrayHat
Purple Team Exercise Hands-On Workshop #GrayHat
Jorge Orchilles871 views
Cấu hình Router cơ bản(Cisco) by NamPhmHoi1
Cấu hình Router cơ bản(Cisco)Cấu hình Router cơ bản(Cisco)
Cấu hình Router cơ bản(Cisco)
NamPhmHoi126.7K views
Embedded Android Workshop with Oreo by Opersys inc.
Embedded Android Workshop with OreoEmbedded Android Workshop with Oreo
Embedded Android Workshop with Oreo
Opersys inc.5.9K views
Window manager활용하기 곽근봉 by keunbong kwak
Window manager활용하기 곽근봉Window manager활용하기 곽근봉
Window manager활용하기 곽근봉
keunbong kwak1.3K views
Slide thuyet trinh android by kuto92love
Slide thuyet trinh androidSlide thuyet trinh android
Slide thuyet trinh android
kuto92love6.4K views
Pentesting Android Apps using Frida (Beginners) by Chandrapal Badshah
Pentesting Android Apps using Frida (Beginners)Pentesting Android Apps using Frida (Beginners)
Pentesting Android Apps using Frida (Beginners)
Chandrapal Badshah6.9K views
Pentesting iOS Applications by jasonhaddix
Pentesting iOS ApplicationsPentesting iOS Applications
Pentesting iOS Applications
jasonhaddix24.7K views
Android - Thread, Handler and AsyncTask by Hoang Ngo
Android - Thread, Handler and AsyncTaskAndroid - Thread, Handler and AsyncTask
Android - Thread, Handler and AsyncTask
Hoang Ngo23.5K views
Báo Cáo Thực Tập PowerPoint by Khôi Nguyễn
Báo Cáo Thực Tập PowerPointBáo Cáo Thực Tập PowerPoint
Báo Cáo Thực Tập PowerPoint
Khôi Nguyễn1.1K views

Similar to MDAD 3 - Basics of UI Applications

MDAD 4 - Android - Basics of UI Applications by
MDAD 4 - Android - Basics of UI ApplicationsMDAD 4 - Android - Basics of UI Applications
MDAD 4 - Android - Basics of UI ApplicationsAlexandru Radovici
292 views41 slides
Android development - the basics, MFF UK, 2013 by
Android development - the basics, MFF UK, 2013Android development - the basics, MFF UK, 2013
Android development - the basics, MFF UK, 2013Tomáš Kypta
1.3K views73 slides
MDAD 3 - Android - System, Platform and Application Types by
MDAD 3 - Android - System, Platform and Application TypesMDAD 3 - Android - System, Platform and Application Types
MDAD 3 - Android - System, Platform and Application TypesAlexandru Radovici
316 views39 slides
Matteo Gazzurelli - Introduction to Android Development - Have a break edition by
Matteo Gazzurelli - Introduction to Android Development - Have a break editionMatteo Gazzurelli - Introduction to Android Development - Have a break edition
Matteo Gazzurelli - Introduction to Android Development - Have a break editionDuckMa
598 views61 slides
Android - Android Application Configuration by
Android - Android Application ConfigurationAndroid - Android Application Configuration
Android - Android Application ConfigurationVibrant Technologies & Computers
109 views49 slides
Android development - the basics, MFF UK, 2014 by
Android development - the basics, MFF UK, 2014Android development - the basics, MFF UK, 2014
Android development - the basics, MFF UK, 2014Tomáš Kypta
1K views69 slides

Similar to MDAD 3 - Basics of UI Applications(20)

MDAD 4 - Android - Basics of UI Applications by Alexandru Radovici
MDAD 4 - Android - Basics of UI ApplicationsMDAD 4 - Android - Basics of UI Applications
MDAD 4 - Android - Basics of UI Applications
Alexandru Radovici292 views
Android development - the basics, MFF UK, 2013 by Tomáš Kypta
Android development - the basics, MFF UK, 2013Android development - the basics, MFF UK, 2013
Android development - the basics, MFF UK, 2013
Tomáš Kypta1.3K views
MDAD 3 - Android - System, Platform and Application Types by Alexandru Radovici
MDAD 3 - Android - System, Platform and Application TypesMDAD 3 - Android - System, Platform and Application Types
MDAD 3 - Android - System, Platform and Application Types
Alexandru Radovici316 views
Matteo Gazzurelli - Introduction to Android Development - Have a break edition by DuckMa
Matteo Gazzurelli - Introduction to Android Development - Have a break editionMatteo Gazzurelli - Introduction to Android Development - Have a break edition
Matteo Gazzurelli - Introduction to Android Development - Have a break edition
DuckMa598 views
Android development - the basics, MFF UK, 2014 by Tomáš Kypta
Android development - the basics, MFF UK, 2014Android development - the basics, MFF UK, 2014
Android development - the basics, MFF UK, 2014
Tomáš Kypta1K views
Matteo Gazzurelli - Andorid introduction - Google Dev Fest 2013 by DuckMa
Matteo Gazzurelli - Andorid introduction - Google Dev Fest 2013Matteo Gazzurelli - Andorid introduction - Google Dev Fest 2013
Matteo Gazzurelli - Andorid introduction - Google Dev Fest 2013
DuckMa665 views
Introduction to Android Development and Security by Kelwin Yang
Introduction to Android Development and SecurityIntroduction to Android Development and Security
Introduction to Android Development and Security
Kelwin Yang11.7K views
Introduction to Android Development by Can Elmas
Introduction to Android DevelopmentIntroduction to Android Development
Introduction to Android Development
Can Elmas1K views
Intro to Building Android Games using libGDX by Jussi Pohjolainen
Intro to Building Android Games using libGDXIntro to Building Android Games using libGDX
Intro to Building Android Games using libGDX
Jussi Pohjolainen2.9K views
Live Memory Forensics on Android devices by Nikos Gkogkos
Live Memory Forensics on Android devicesLive Memory Forensics on Android devices
Live Memory Forensics on Android devices
Nikos Gkogkos9.9K views
Don Thorp & Marshall Culpepper: Advanced Titanium Development for Android by Axway Appcelerator
Don Thorp & Marshall Culpepper: Advanced Titanium Development for AndroidDon Thorp & Marshall Culpepper: Advanced Titanium Development for Android
Don Thorp & Marshall Culpepper: Advanced Titanium Development for Android
Axway Appcelerator870 views
Android development - the basics, MFF UK, 2012 by Tomáš Kypta
Android development - the basics, MFF UK, 2012Android development - the basics, MFF UK, 2012
Android development - the basics, MFF UK, 2012
Tomáš Kypta975 views
Android app development: a top-down perspective by Chao-Chueh Chang
Android app development: a top-down perspectiveAndroid app development: a top-down perspective
Android app development: a top-down perspective
Chao-Chueh Chang858 views
Android Jumpstart Jfokus by Lars Vogel
Android Jumpstart JfokusAndroid Jumpstart Jfokus
Android Jumpstart Jfokus
Lars Vogel1.3K views
Reproducibility and automation of machine learning process by Denis Dus
Reproducibility and automation of machine learning processReproducibility and automation of machine learning process
Reproducibility and automation of machine learning process
Denis Dus2.3K views
2006 - Basta!: Advanced server controls by Daniel Fisher
2006 - Basta!: Advanced server controls2006 - Basta!: Advanced server controls
2006 - Basta!: Advanced server controls
Daniel Fisher252 views
Extending Android's Platform Toolsuite by Opersys inc.
Extending Android's Platform ToolsuiteExtending Android's Platform Toolsuite
Extending Android's Platform Toolsuite
Opersys inc.1.1K views

More from Alexandru Radovici

SdE2 - Pilot Tock by
SdE2 - Pilot TockSdE2 - Pilot Tock
SdE2 - Pilot TockAlexandru Radovici
245 views22 slides
SdE2 - Systèmes embarquées by
SdE2 - Systèmes embarquéesSdE2 - Systèmes embarquées
SdE2 - Systèmes embarquéesAlexandru Radovici
135 views41 slides
SdE2 - Planification, IPC by
SdE2 - Planification, IPCSdE2 - Planification, IPC
SdE2 - Planification, IPCAlexandru Radovici
249 views54 slides
ALF1 - Introduction by
ALF1 - IntroductionALF1 - Introduction
ALF1 - IntroductionAlexandru Radovici
401 views33 slides
SdE2 - Introduction by
SdE2 - IntroductionSdE2 - Introduction
SdE2 - IntroductionAlexandru Radovici
479 views53 slides
MDAD 6 - AIDL and Services by
MDAD 6 - AIDL and ServicesMDAD 6 - AIDL and Services
MDAD 6 - AIDL and ServicesAlexandru Radovici
288 views23 slides

More from Alexandru Radovici(20)

Recently uploaded

UNIDAD 3 6º C.MEDIO.pptx by
UNIDAD 3 6º C.MEDIO.pptxUNIDAD 3 6º C.MEDIO.pptx
UNIDAD 3 6º C.MEDIO.pptxMarcosRodriguezUcedo
124 views32 slides
MercerJesse2.1Doc.pdf by
MercerJesse2.1Doc.pdfMercerJesse2.1Doc.pdf
MercerJesse2.1Doc.pdfjessemercerail
237 views5 slides
AUDIENCE - BANDURA.pptx by
AUDIENCE - BANDURA.pptxAUDIENCE - BANDURA.pptx
AUDIENCE - BANDURA.pptxiammrhaywood
89 views44 slides
Computer Introduction-Lecture06 by
Computer Introduction-Lecture06Computer Introduction-Lecture06
Computer Introduction-Lecture06Dr. Mazin Mohamed alkathiri
102 views12 slides
Solar System and Galaxies.pptx by
Solar System and Galaxies.pptxSolar System and Galaxies.pptx
Solar System and Galaxies.pptxDrHafizKosar
94 views26 slides
The basics - information, data, technology and systems.pdf by
The basics - information, data, technology and systems.pdfThe basics - information, data, technology and systems.pdf
The basics - information, data, technology and systems.pdfJonathanCovena1
126 views1 slide

Recently uploaded(20)

AUDIENCE - BANDURA.pptx by iammrhaywood
AUDIENCE - BANDURA.pptxAUDIENCE - BANDURA.pptx
AUDIENCE - BANDURA.pptx
iammrhaywood89 views
Solar System and Galaxies.pptx by DrHafizKosar
Solar System and Galaxies.pptxSolar System and Galaxies.pptx
Solar System and Galaxies.pptx
DrHafizKosar94 views
The basics - information, data, technology and systems.pdf by JonathanCovena1
The basics - information, data, technology and systems.pdfThe basics - information, data, technology and systems.pdf
The basics - information, data, technology and systems.pdf
JonathanCovena1126 views
CUNY IT Picciano.pptx by apicciano
CUNY IT Picciano.pptxCUNY IT Picciano.pptx
CUNY IT Picciano.pptx
apicciano54 views
ISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks Effectively by PECB
ISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks EffectivelyISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks Effectively
ISO/IEC 27001 and ISO/IEC 27005: Managing AI Risks Effectively
PECB 598 views
Pharmaceutical Inorganic Chemistry Unit IVMiscellaneous compounds Expectorant... by Ms. Pooja Bhandare
Pharmaceutical Inorganic Chemistry Unit IVMiscellaneous compounds Expectorant...Pharmaceutical Inorganic Chemistry Unit IVMiscellaneous compounds Expectorant...
Pharmaceutical Inorganic Chemistry Unit IVMiscellaneous compounds Expectorant...
Ms. Pooja Bhandare109 views
Narration lesson plan by TARIQ KHAN
Narration lesson planNarration lesson plan
Narration lesson plan
TARIQ KHAN59 views
The Accursed House by Émile Gaboriau by DivyaSheta
The Accursed House  by Émile GaboriauThe Accursed House  by Émile Gaboriau
The Accursed House by Émile Gaboriau
DivyaSheta212 views
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB... by Nguyen Thanh Tu Collection
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
Ch. 7 Political Participation and Elections.pptx by Rommel Regala
Ch. 7 Political Participation and Elections.pptxCh. 7 Political Participation and Elections.pptx
Ch. 7 Political Participation and Elections.pptx
Rommel Regala105 views
Create a Structure in VBNet.pptx by Breach_P
Create a Structure in VBNet.pptxCreate a Structure in VBNet.pptx
Create a Structure in VBNet.pptx
Breach_P75 views
11.28.23 Social Capital and Social Exclusion.pptx by mary850239
11.28.23 Social Capital and Social Exclusion.pptx11.28.23 Social Capital and Social Exclusion.pptx
11.28.23 Social Capital and Social Exclusion.pptx
mary850239304 views
Monthly Information Session for MV Asterix (November) by Esquimalt MFRC
Monthly Information Session for MV Asterix (November)Monthly Information Session for MV Asterix (November)
Monthly Information Session for MV Asterix (November)
Esquimalt MFRC58 views
Class 9 lesson plans by TARIQ KHAN
Class 9 lesson plansClass 9 lesson plans
Class 9 lesson plans
TARIQ KHAN47 views
How to empty an One2many field in Odoo by Celine George
How to empty an One2many field in OdooHow to empty an One2many field in Odoo
How to empty an One2many field in Odoo
Celine George72 views

MDAD 3 - Basics of UI Applications

  • 1. Android Basics of UI Applications
  • 2. Bibliography 1. Wallace Jackson, Android Apps for Absolute Beginners, Apress, 2017 2. Peter Späth, Learn Kotlin for Android Development, Apress 2019 3. Android Application Fundamentals, http://developer.android.com/guide/topics/f undamentals.html 2
  • 3. Let’s recap • Android – OS – Platform – Kernel – User space libraries – Hardware Abstraction Layer – Dalvik / ART – Android Libraries – Applications • Android Applications – Types – Security 3
  • 4. Contents • Containers • Resources • Build GUI with XML • Intents • Manifest • Toast 4
  • 6. Task (UI Application) • Runs in one process – usually! – There are exceptions • Stack of activities • Root activity – Add • Display • push – Remove • Hide • pop – Activities from other applications 6
  • 7. Important Functions • Clasa Activity – void onCreate (…); – void onStart (…); – void onRestart (…); – void onResume (…); – void onPause (…); – void onStop (…); – void onDestroy (…); • Must call the parent overridden functions • super.onCreate (…); – … 7
  • 8. Storing and loading of the status • Store – void onSaveInstanceState (Bundle state) • Load – void onLoadInstanceState (Bundle state) – void onCreate (Bundle savedInstance) 8
  • 9. Components (Widgets) • Extend View • Placed on an Activity – Static • TextView • ProgressBar • ImageView • … – Dynamic • Button • EditText • CheckBox • RadioButton • SeekBar • Spinner • Gallery • MapView • ListView • … 9
  • 10. Container • View – Contains other Views – Layout • Types (outdated) – LinearLayout – RelativeLayout – TableLayout – ScrollLayout • They are used combined 10
  • 13. Resources • res folder (from the source) • Images – drawable -_dpi • ldpi • mdpi • hdpi • UI – layout • Constants – Values • strings.xml • Raw – Unmodifiable resources 13
  • 14. Automatic resources in Java code • Drawable – Images – R.drawable.name • R.drawable.icon • R.drawable.img1 • R.drawable.img2 • Layout – Containers – R.layout.name • R.layout.main • R.layout.people 14
  • 15. Automatic resources in XML • Drawable – Images – @drawable/name • @drawable/icon • @drawable/img1 • @drawable/img2 • Layout – Containers – @layout/name • @layout/main • @layout/people 15
  • 16. Constructing the GUI with XML • Complex component • Simple code • No Java code • In the Activity code – this.setContentView (R.layout.name); 16
  • 17. GUI XML example file 17
  • 18. GUI XML example file • xmlns:android – Only the root component – mandatory • android:layout_width • android:layout_height – mandatory – Values • fill_parent • wrap_content • match_parent • n px • n cm 18
  • 19. GUI XML example file • android:id – Usage of the component in the Java code – @+id/name • R.id.name – Example • @+id/button1 – R.id.button1 19
  • 20. GUI XML example file • android:id – Usage of the component in the Java code – @+id/name • R.id.name – Example • @+id/button1 – R.id.button1 20
  • 21. GUI XML example file XML Java Code 21
  • 22. Menu • MENU (soft) button press • Events – public boolean onCreateOptionsMenu (Menu menu); – public boolean onOptionsItemSelected(MenuItem item); • Adding a menu – menu.add (…); 22
  • 24. Menu using XML XML (res/menu/meniu.xml) Java Code 24
  • 25. Menu using XML • XML (res/menu/meniu.xml) 25
  • 26. Menu using XML • Java Code 26
  • 27. Intents • Intent – A component that wants something • Generates events – Phone call – Send sms • Object 27
  • 28. The intent is described by • Action • Data • Category • Type • Component • Extras 28
  • 29. Action • Desired action – Call – Send sms – Open document – Edit document – Start an activity • String – “android.intent.action.MAIN” – “android.intent.action.VIEW” 29
  • 30. Action example • ACTION_MAIN • ACTION_VIEW • ACTION_EDIT • ACTION_PICK • ACTION_CHOOSER • ACTION_GET_CONTENT • ACTION_DIAL • ACTION_CALL • ACTION_SEND • ACTION_SENDTO • ACTION_ANSWER • ACTION_SEARCH • ACTION_WEB_SEARCH • … 30
  • 31. Exampe of informative action • ACTION_TIME_TICK • ACTION_TIME_CHANGED • ACTION_TIMEZONE_CHANGED • ACTION_BOOT_COMPLETED • ACTION_PACKAGE_ADDED • ACTION_PACKAGE_CHANGED • ACTION_PACKAGE_REMOVED • ACTION_PACKAGE_RESTARTED • ACTION_PACKAGE_DATA_CLEARED • ACTION_UID_REMOVED • ACTION_BATTERY_CHANGED • ACTION_POWER_CONNECTED • ACTION_POWER_DISCONNECTED • ACTION_SHUTDOWN 31
  • 32. Data • Associated data • Usually an URI – tel:123 – content://contacts/… – File:///sdcard/... 32
  • 33. Category • Defines better the action – CATEGORY_LAUNCHER – CATEGORY_ALTERNATIVE – CATEGORY_DEFAULT • Additional information • Optional • String – "android.intent.category.MAIN“ – "android.intent.category.ALTERNATIVE" 33
  • 34. Category example • CATEGORY_DEFAULT • CATEGORY_BROWSABLE • CATEGORY_TAB • CATEGORY_ALTERNATIVE • CATEGORY_SELECTED_ALTERNATIVE • CATEGORY_LAUNCHER • CATEGORY_INFO • CATEGORY_HOME • CATEGORY_PREFERENCE • CATEGORY_TEST • CATEGORY_CAR_DOCK • CATEGORY_DESK_DOCK • CATEGORY_CAR_MODE 34
  • 35. Type • Data type – It is generally determined in • file:///sdcard/poze/poza.jpg – It has priority over • Optional • String – “image/jpg” – “contacts/contact” 35
  • 36. Component • Mentions the specific destination component • Optional • Start/Stop – Activities • startActivity (…) • finishActivity (…) – Services • startService (…) • stopService (…) 36
  • 37. Extras • Extra data • Bundle – putExtra () – getStringExtra () – getIntExtra () – getBooleanExtra () – … 37
  • 38. Usage • Functions which emit intents – void startActivity (Intent i) – void startService (Intent i) – void sendBroadcast (Intent i, String permission) • The system searches for the appropriate component – Intent Resolution 38
  • 39. Search for the activity • Filter arguments – ACTION – TYPE (usually extracted from DATA) – CATEGORY • Determined – Determines the appropriate component – Determines the appropriate components list 39
  • 40. IntentFilters • Components that declare filters – Activities – Services – BoradcastReceivers • Windows equivalent – File association • In AndroidManifest.xml 40
  • 41. Example The applications menu asks for a list of components that respond to Action: ACTION_MAIN Category: CATEGORY_LAUNCHER 41
  • 44. Manifest AndroidManifest.xml – Declare components (Activities, Services, etc) – Declare permissions 44
  • 45. Starting of an activity • context.startActivity (Intent intent); Intent starter = new Intent (context, ActivityClass.class); context.startActivity (starter); 45
  • 46. Stopping an activity • context.finishActivity (Intent intent); – Another component wants to stop the Activity • finish (); – The Activity stops itself Intent starter = new Intent (context, ActivityClass.class); Context.finishActivity (starter); 46
  • 47. Toast • Display notifications – Short • Toast.LENGTH_SHORT – Long • Toast.LENGTH_LONG • Toast 47
  • 48. Conclusions • Task – A stack of activities • Intents • Manifest – Declare activities • Automatic Resources – Drawable • R.drawable.nume • @/drawable/nume – Layout • Fișiere XML • R.layout.nume • @/layout/nume • Toast – Display messages 48
  • 49. Keywords • Task – Stack • Activity – Lifecycle • Containers – Layouts – LinearLayout – TableLayout – RelativeLayout – GridLayout • Toast • XML GUI • Menu • Manifest • Components – Static • TextView • ProgressBar • ImageView • … – Dynamic • Button • EditText • CheckBox • RadioButton • SeekBar • Spinner • Gallery • MapView • ListView 49